Reputation: 3711
I'm playing around with AngularJS (and trying to get my head round it) and have a controller which for the purpose of this question can be simplified to:
$scope.addMessage = function() {
$scope.messages.push({author: 'nick',
text: $scope.messageText, active: true});
};
Every time that the model changes due to this '$scope.addMessage' I want to run emojify.run();
... If I simply put it after $scope.messages.push...
it runs before the data is shown in the view and therefore doesn't work. How do I call the function emojify.run();
once the view has updated?
Upvotes: 1
Views: 797
Reputation: 583
I think you need to use the scope.$watch listener on your model
See this tutorial that does something similar: http://www.youtube.com/watch?v=8ozyXwLzFYs
$watch is called in the $digest phase. For details see the Scope lifecycle here: http://docs.angularjs.org/guide/scope
Upvotes: 1