Hey Guys!
I’ve updated from beta7 to beta8
Changed my @App to @Component in app.ts
I had a whole bunch of custom directives in @App that worked throughout all the pages in the project. Now it appears that they no longer work apart from in the app template.
Do I have to now register all my custom directives throughout all the pages? or Is there a global way I can register them?
Cheers,
Ryan
You would register them on your root component annotation
@Component({
templateUrl: 'path/to/app.html',
directives: [Componen1, Component2, Component3]
})
Plus, importing them into the app.ts file.
This does not seem to work if you want the directives to be available globally (if I understand you correctly).
Instead I have set the customDirectives parameters for the ionicBootstrap method like this:
ionicBootstrap(MyApp, [
{
provide: PLATFORM_DIRECTIVES, useValue: [MyDirective1, MyDirective2, MyDirective3], multi: true
}
]);
See MULTI PROVIDERS IN ANGULAR 2 for more info (note: deprecated provide method syntax) and The provide object literal for the new syntax (Angular 2 RC1).
3 Likes
I can confirm the above works for me. Registering them in the root component does not.