Skip to content

Automatically load/inject the most commonly used directives into all templates #1586

@un33k

Description

@un33k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions