angularjs - angular $apply doesn't update model property changes with webix datatable -


the code below not render changes on each setinterval period. however, if push record using addrecord, changes start populate. appears $apply looks record count changes. there way go this? how can re-render model without having add record?

$scope.records = [     { id:1, title:"the shawshank redemption", year:1994, votes:678790, rating:9.2, rank:1},     { id:2, title:"the godfather", year:1972, votes:511495, rating:9.2, rank:2},     { id:3, title:"the godfather: part ii", year:1974, votes:319352, rating:9.0, rank:3},     { id:4, title:"the good, bad , ugly", year:1966, votes:213030, rating:8.9, rank:4},     { id:5, title:"my fair lady", year:1964, votes:533848, rating:8.9, rank:5},     { id:6, title:"12 angry men", year:1957, votes:164558, rating:8.9, rank:6}   ];     $scope.addrecord = function(){     $scope.records.push({         title:"new record",         rating:999,         votes:0,         year:2013     });   };    $scope.random = function(){      $scope.records.foreach( function(v,k){         $scope.$apply(             function(){ v.votes = math.random(); }         );     });    }    setinterval( function(){     console.log('wtf');     $scope.random(  );   }, 1000); 

update: issue caused webix library i'm using datatables. i'm assuming webix has $apply method need called after update.

<body ng-controller="webixtestcontroller">  <div> {{records}} </div>  <div style="width:750px;">   <div webix-ui view="datatable" webix-data="records" autoheight="true" select="row">     <div view="column" id="rating" sort="int" css="rating">rating</div>     <div view="column" id="year"   sort="int">year</div>     <div view="column" id="votes"  sort="int">votes</div>     <div view="column" id="title"  sort="string" fillspace="1">title</div>     </div> </div>  <br> <button ng-click="addrecord()">add row</button> </body> 

http://docs.webix.com/api_link_ui.datatable_refresh.html

webix requires use of refresh() on datatable updated model take affect.

$scope.records.foreach( function(v,k){     $scope.$apply(         function(){ v.votes = math.random(); }     ); }); $$("table").refresh(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -