Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  129] [ 4]  / answers: 1 / hits: 146358  / 10 Years ago, tue, april 22, 2014, 12:00:00

I'm working in a small team, building in AngularJS and trying to maintain some basic standards & best practices; especially given we're relatively new with Angular.



My question is with regards to Directives. More accurately, the restrict options.



Some of us are using restrict: 'E' thus having <my-directive></my-directive> in the html.



Others are using restrict: 'A' and having <div my-directive></div> in the html.



Then, of course, you can use restrict: 'EA' and use either of the above.



At the moment it's no big deal, though when this project is as big as it's going to get I would like anybody looking at it to easily understand what's going on.



Are there pros/cons to either the attribute or element way of doing things?



Are there any pitfalls we should know, if choosing say element over attribute?


More From » html

 Answers
14

According to the documentation:




When should I use an attribute versus an element? Use an element when
you are creating a component that is in control of the template. The
common case for this is when you are creating a Domain-Specific
Language for parts of your template. Use an attribute when you are
decorating an existing element with new functionality.




Edit following comment on pitfalls for a complete answer:



Assuming you're building an app that should run on Internet Explorer <= 8, whom support has been dropped by AngularJS team from AngularJS 1.3, you have to follow the following instructions in order to make it working: https://docs.angularjs.org/guide/ie


[#71348] Sunday, April 20, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
3 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;