I have a template that gets data from the service. The data in the service is updated by the directive.
After the data is updated, it will not be updated in the template.
// In my template {{Service.get ()}} // In my service. Service ('service', function ($ http) {var _val = 5; return {get: function} {return val;}, set: function (val) {_val = val;}};}); // Some directives in my directive = angular Module ('apps directive', []); Some Directive Directive ('Some Directive', ['Service', Function] {Return Function (Scope, Element, ethers) {$ (Element). On ('Scroll', Function (Event) {service.set (15 );});};}]);
If I call service.set (x) to another location (like another controller) it works 100% fine.
Perhaps someone knows what I did wrong. (Thank you very much)
Edit To make it a little more clear:
When the page loads, '5' is displayed ( right). But when the value should be updated, the service.set () - function is called correctly (from the Directorate), but there is no change in the template.
If I call service.set () anyother else, it works (value has been updated in the template).
You are the easiest to go outside the event digest cycle:
$ Timeout (function () {service.set (15);});
Comments
Post a Comment