#In a template, can I attach an object to an element that isn't the root element of the component?
11 messages · Page 1 of 1 (latest)
I ended up writing an attribute directive that adds it as a property
if cannot use data-* any where ? then i am loosing the power for the using inbuilt functionality for the element right.
I mean , i am not able to bind value to the data-* attributes.
You can if your data is just a string
i mean dyanmic data i want to
The string can be dynamic. You just can't use objects, arrays etc
[data-id]="test" in template and test="test" in ts did these.
Error: apps/recipe-app/src/app/ingredient/ingredient.component.html:1:6 - error NG8002: Can't bind to 'data-id' since it isn't a known property of 'div'.
Try [attr.data-id]
works man, Thank you a lot