Hi,
I try create dynamically dropdowns by click on the button.
Every dropdown is filled with names.
The problem is for example if I click 3 times on the button and I create a
3 dropdowns and then I select in first dropdown option number 2 (for
example), all of 3 dropdowns change to this option.
I understan that the reason is a same ng-model in every dropdown.
How can I change the ng-model of the new drop down every time when i click
the button?
js code:
function myCntrl2($scope,$compile){
$scope.members =
[
{
"name":"John",
"id":"1"
},
{
"name":"Dima",
"id":"2"
},
{
"name":"vova",
id:3
}
];
$scope.add_el=function(){
var html='<br><select ng-model=members data-ng-options="member as
member.name for member in members">
</select>'
angular.element(document.getElementById('myID')).append($compile(html)($scope))
};
HTML code:
<div id=myID ng-controller="myCntrl2">
<button id="test" type="button" ng-click="add_el()"></button>
</div>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.