mardi 27 décembre 2016

How to avoid old value flashed after view updated in Angular?

In my angular app, there is an main app component which have a event listener:

...
$scope.$on('page::change', function(e, value) {
  self.navList = value;
});
...

And a navigation component inside app component, it has only one varible which bind to navList inside app component:

app.component('navBar', {
  bindings: {
    list: '<',
  },
  templateUrl: 'templates/e/navBar.html',
  ...
});

Inside navBar.html, I use ng-repeat to display the data of 'list':

<nav>
    <a ng-repeat="(key,value) in Nav.list" ng-href="" ng-bind="key"></a>
</nav>

Whenever I change the value of navList inside the app, or I emit an event of 'page::change', the view of data will flash in webpage like:

Original:

OldValue

And then flash:

NewValue OldValue

Then finally:

NewValue

How should I fix this? The version of anuglar is 1.5.8




Aucun commentaire:

Enregistrer un commentaire