Angularjs - Directives: Element or Attribute

Asked

Viewed 223 times

2

I’m new to Angularjs and I’m looking at the Directives part, and I’m seeing that there is a restrict element and a restrict attribute. I understood what each one does, but it was not clear when I should use one or the other, or both?

1 answer

3


You are free to use both when you feel like it, but in some cases it is more worth using instead of the other.

Directives as an element is a good request when you are working with repetitive HTML snippets that could be isolated for example, but nothing prevents you from using directives as attributes to perform the same procedure.

Directives as attribute is a good request for validations in elements of type input for example, but in this case it would not be possible to do the same through directives as element.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.