forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Best Practices
Dean Sofer edited this page Aug 26, 2013
·
21 revisions
-
Namespace distributed code
This means usingbs-orui-or something. You could use your initials if you want but you may find it becomes more meaningful if you prefix code by relevant grouping breakdowns (such asloc-for location services ori18n-for translation) -
Only use
.$broadcast(),.$emit()and.$on()for atomic events
This means events that are relevant globally across the entire app (such as a user authenticating or the app closing). If you want events specific to modules, services or widgets you should consider Services, Directive Controllers, or 3rd Party Libs -
Support
{{}}in all string attributes using$attrs.$observe()
When building a directive that supports string-value-only attributes, always allow the user to provide expressions, likeng-hrefandng-src. -
Extend directives by using Directive Controllers
You can place methods and properties into a directive-controller, and access that same controller from other directives. You can even override methods and properties through this relationship