Answer the question
In order to leave comments, you need to log in
How in Angular js to use an object in its directive passed through ng-model?
For example there is <my-directive ng-model="object"></my-directive>
How to get this object in a directive to use for example:
.directive('myDirective', function(){
return {
template: '<div>{{object.elem1}}</div>'
}
})
Answer the question
In order to leave comments, you need to log in
I don't really understand why you do that, here's the answer:
return {
template: '<div>{{elem1}}</div>',
link: function(scope, el, attrs){
scope.elem1 = attrs.ngModel;
}
}
return {
template: '<div>{{obj.elem1}}</div>',
scope: {
obj: '='
},
link: function(scope, el, attrs){
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question