Directives like {If, Foreach, For ... etc.) are often used in many templates. To simplify the process and in the spirit of writing less code and for the sake of maintainability, It might be a good idea to have a pre_loader API where the project can pass in the common directives in and on startup all templates are pre-injected with the common directives.
Example:
import {pre_loader, If, For, Foreach} from 'angular2/angular2';
pre_loader('directives', [IF, For, Foreach]);
@template({
url: 'templates/main.html',
directives: [MyOwnDirective]
})
With the above approach, the directives passed into the template would be IF, For, Foreach & MyOwnDirective.
The catch is to have pre_loader('directives', [IF, For, Foreach]); executed before anything else.
The pre_loader() function can also be used for configs other than directives.
Directives like {If, Foreach, For ... etc.) are often used in many templates. To simplify the process and in the spirit of writing less code and for the sake of maintainability, It might be a good idea to have a
pre_loaderAPI where the project can pass in the common directives in and on startup all templates are pre-injected with the common directives.Example:
import {pre_loader, If, For, Foreach} from 'angular2/angular2';
pre_loader('directives', [IF, For, Foreach]);
@template({
url: 'templates/main.html',
directives: [MyOwnDirective]
})
With the above approach, the directives passed into the template would be IF, For, Foreach & MyOwnDirective.
The catch is to have
pre_loader('directives', [IF, For, Foreach]);executed before anything else.The
pre_loader()function can also be used for configs other than directives.