I\'m writing an Angular 1.5 directive and I\'m running into an obnoxious issue with trying to manipulate bound data before it exists.
Here\'s my code:
ap
I had a similar problem and I found this article very helpful. http://blog.thoughtram.io/angularjs/2016/03/29/exploring-angular-1.5-lifecycle-hooks.html
I have an ajax call that hits the server on page load and my component needs the ajax return value to properly load. I implemented it this way:
this.$onChanges = function (newObj) {
if (newObj.returnValFromAJAX)
this.returnValFromAJAX = newObj.returnValFromAJAX;
};
Now my component works perfectly. For reference I am using Angular 1.5.6