angularjs - View(Template) does not update when the controller changes -
i have directive pushes element array, , shows elements on view, problem though array gets updated (the log shows correct values) view keeps showing empty array. doing wrong?
note: not need parent's $scope anything, i'm adding/modifying on directive's scope.
directive:
app.directive('streaming', function(){ return { restrict: 'ea', scope: { live: '&', data: '&', }, controller: function($scope){ $scope.messages=[]; //..... //eventually reaches $scope.messages.push({..}); }, templateurl: '/directives/templates/streaming.html' }});
template:
<div class="row" > <canvas id="canvas" width="640px" height="360px"></canvas> </div> <div ng-show="live" id="chat"> {{messages}} <div ng-repeat="m in messages"> <div ng-if="m.type==0"><!--sistema--> {{m.val}} </div> <div ng-if="m.type==1"><!--usuario--> {{m.val}} </div> </div> </div>
i had wrap $scope.messages
modifications in $scope.apply()
view reflect actual value. i'm not entirely sure why. solved problem
Comments
Post a Comment