angularjs - Angular directive watch not updating -
angularjs - Angular directive watch not updating -
html of view
<div class="container-fluid" ng-controller="searchcontroller search"> <pretty-print displayfilecontents="search.displayfilecontents"></pretty-print> </div> directive setup
app.directive("prettyprint", function() { return{ restrict: "e", scope: { displayfilecontents: "=" }, template: '<pre id="code" class="prettyprint linenums">{{displayfilecontents}}</pre>', link: function(scope, element, attrs) { scope.$watch("displayfilecontents", function () { element.html(scope.displayfilecontents); prettyprint(); },true); }} }) for reason watch on "displayfilecontents" comes undefined scope.displayfilecontents
search.displayfilecontents has value in searchcontroller...i can print html in view , outputs code, want phone call prettyprint() 1 time gets loaded.
angularjs angularjs-directive angularjs-scope
Comments
Post a Comment