Answer the question
In order to leave comments, you need to log in
How to properly add elements in Angular?
Hello!
Is it correct to add elements like this
if($('#selected_accessApplication_'+access.originalObject.id).length == 0)
{
$('#selectedAccessApplication').append('<div class='selected'></div>')
}
Answer the question
In order to leave comments, you need to log in
$scope.items = [1,2,3];
$scope.items.push(4);
<div ng-repeat="item in intems">{{item}}</div>
<button ng-click="items.push(5)">add</button>
What you wrote is working with the DOM directly. This is valid if you do it inside a directive, but then you need to select from the element on which the directive is hung and try not to go beyond this very element.
In your case, it would be more correct to use ng-repeat and date binding. Actually, if I understand correctly what you want to do - this is the only way you need to do it, otherwise the meaning of using angular is lost. You have no isolation in the end, work with some strange variables, the logic of the application is associated with the view .... word ... fu
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question