Reputation: 8411
Edit
How to set for this <input ng-model="this['newPlayer']['personal_info']['first_name']">
the ['newPlayer']['personal_info']['first_name']
dynamically from variable?
Something like this: <input ng-model="this[variable]">
Upvotes: 0
Views: 68
Reputation: 1381
You don't have to get it from the attributes just add this to your directive require: 'ngModel'
like this
app.directive("textInput", () => {
return {
templateUrl: "/text-input.html",
require: 'ngModel'
scope: true,
link: function($scope, $element, $attrs, ngModel) {
angular.element($element).append($scope[$attrs.myModel]);
}
}
});
and you have your different ngModel
for each textInput instance in link function
Upvotes: 2