I am trying to update a model from a directive and have some problems when $ apply or $ digest is already running. And I have a few questions:
- Why
scope[attrs.ngModel] exist, but ngModel.$modelValue not in the $ apply phase? - Why might the view not always be updated in the $ digest phase (especially in difficult situations)?
- Whether $ digest is a local $ digest () or $ root phase. $ digest () (from $ apply ()) in my example?
require: '?ngModel', link: function(scope, element, attrs, ngModel) { element.bind('myEvent', function(e) {
Live demo: http://plnkr.co/edit/gVY6GJejEKCLdTIXNAzK?p=preview
source share