I have a simple app that uses Angular to run a HTTP GET request and then sets the returned data to an array that is bound to the DOM using ng-repeat
and I want to run some code that manipulates this DOM after it is done being placed into the body
. What is the best way to make this work?
$http({
method: 'GET',
url: 'https://www.*******.com/WebApi/Alert/Items/all',
cache: false
})
.success(function (data, status) {
$scope.alerts = data.result.Alerts;
jQuery('.aWidget').iconalt(); // THIS IS THE CODE I WANT TO RUN
})
.error(function (data, status) {
console.log(data);
alert("error");
});
See, I want to run the line jQuery('.aWidget').iconalt()
after all the DOM is placed into the document. Right now, this line is executing too fast and so it "thinks" that there are no .aWidget
elements in the DOM
Is there some kind of callback that I can inject into AngularJS that gets called after the DOM is loaded?