I am currently working with Angular. My situation is below.
I then want to take that selected entry (which is stored as the 'selected' object) and output that into a different HTML section titled "Contact Information". This section of HTML is stored in a directive Template.
How can I dynamically update the template directive that I have, to include the newly populated 'selected' object?
I cannot seem to figure out the correct syntax to transfer the data in that object into the different section.
Pls, hlp.
Try to use an attribute in the directive:
<my-directive selected-item="{{selectedItem}}"></my-directive>
And then in the link
function in the directive just use the attr.selecteditem
:
link: function (scope, iElement, iAttrs) {
scope.selectedItem = iAttrs.selecteditem;
}
Or if you have an isolate scope:
scope: {
selecteditem: '='
},
link: function (scope, iElement, iAttrs) {
console.log(selecteditem);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.