Answer the question
In order to leave comments, you need to log in
How to implement such a directive in Angular?
Hello. I can't figure out how to implement a directive that will have one parameter - the user ID, which will receive information from it and display it.
Those. I want to create something like this directive: <user id='123'></user>
A view for it is in a separate file (This is an example. The real template is much larger): <span>{{user.name}}</span>
I understand how to create a directive that takes some value.
.directive('user', ['profile', function(profile) {
return {
restrict: 'E',
replace: 'true',
templateUrl:'user.html',
scope: {
id:'='
},
};
}])
const user = profile.getById(templateAttrs.id);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question