javascript - Directive is rendering HTML before a variable is given a value -
i running django 1.9 , angularjs 1.5.
my django view looks this:
#hello_world_view.py def hello_world(request): t = get_template('hello-world.html') return httpresponse(t.render())
the html file looks this:
<-- loading javascript files above --> <helloworld><helloworld>
the angularjs controller has promise retrieving data django rest api. looks this
helloworld.controller('helloworldcontroller', function($scope, $helloworldservice1, $helloworldservice2) { promise.all([$hwservice1, $hwservice2]).then(function(response) { $scope.service1 = response[0]; $scope.service2 = response[1]; }); });
the directive looks this:
// helloworld defined app. helloworld.directive('helloworlddirective', function() { return { restrict:'e', link: function($scope, $elements, $attributes) { $scope.$watch('somevariable', function(data) { if (data) { $elements.text(data); } }, true); }, templateurl: '/static/partials/some-template.html' } });
some template has variables inside dependent on promise controller being resolved. however, when test via.
>>> python manage.py runserver
the variables not rendered. changed tags {{}} [[]] angularjs know it's not django accidentally trying render these variables.
is i'm doing possible? if so, there fix? thanks.
edit: fixed grammar.
looks need register controller directive. try adding:
controller: 'helloworldcontroller' return object of directive.
Comments
Post a Comment