Reputation: 39018
Is there an easy way to remove the contents of a div in Angular,
I have <div class="row">
inside of which I have an ng-repeat that generates several widgets. Now if an action takes place from the parent scope
I need to empty that div
and call the function that does the ng-repeat
again.
Upvotes: 0
Views: 754
Reputation: 609
May be you are updating data outside of AngularJS.
You can try scope.$apply or an easier way is to wrap the function in an $timeout without delay:
$timeout(function(){ // Update your data });
Upvotes: 1
Reputation: 1314
Angular watches the variables on its own and adds / deletes / updates the ng-repeat on it's own when the array it lists gets updated.
So there is no need to delete it all first, you can just update the object / widget you'd like OR replace the contents of the array it lists with a new array.
Upvotes: 1
Reputation: 2865
Without code it's kind of hard to answer this, but if the ng-repeat is only thing in your div, if you update the array/object bound to the ng-repeat it will automatically update the contents of the div because the ng-repeat will re-evaluate. You don't have to clear it out. Now, if you have other content in the div, this solution won't work.
Upvotes: 1