Skip to content

Instantly share code, notes, and snippets.

@mikesigs
Forked from awerlang/angular-directives
Last active November 17, 2022 12:49
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mikesigs/331067c0d024513c2c44 to your computer and use it in GitHub Desktop.
Save mikesigs/331067c0d024513c2c44 to your computer and use it in GitHub Desktop.
Angular Directive Priority - Quick Reference

##Angular Directive Priority - Quick Reference

When there are multiple directives defined on a single DOM element, sometimes it is necessary to specify the order in which the directives are applied. The priority is used to sort the directives before their compile functions get called. Priority is defined as a number. Directives with greater numerical priority are compiled first. Pre-link functions are also run in priority order, but post-link functions are run in reverse order. The order of directives with the same priority is undefined. The default priority is 0.

For a brief description of each directive, click here.

Directive Priority Terminal Creates new scope Can be used as multiElement
ngSwitch 1200 X
ngNonBindable 1000 X
ngRepeat 1000 X X X
ngIf 600 X X X
ngController 500 X
ngInit 450
ngInclude 400 X X
ngView 400 X
ngChecked 100
ngDisabled 100
ngOpen 100
ngReadonly 100
ngSelected 100
ngHref 99
ngSrc 99
ngSrcset 99
ngModel 1
a 0
form 0
input 0
ngApp 0
ngBind 0
ngBindHtml 0
ngBindTemplate 0
ngBlur 0
ngChange 0
ngClass 0
ngClassEven 0
ngClassOdd 0
ngClick 0
ngCloak 0
ngCopy 0
ngCsp 0
ngCut 0
ngDblclick 0
ngFocus 0
ngForm 0
ngHide 0 X
ngJq 0
ngKeydown 0
ngKeypress 0
ngKeyup 0
ngList 0
ngMessages 0 X
ngModelOptions 0
ngMousedown 0
ngMouseenter 0
ngMouseleave 0
ngMousemove 0
ngMouseover 0
ngMouseup 0
ngOptions 0 X
ngPaste 0
ngPluralize 0
ngShow 0 X
ngStyle 0
ngSubmit 0
ngTransclude 0
ngValue 0
script 0 X
select 0
textarea 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment