Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See if we can automatically inject IONIC_DIRECTIVES #6092

Closed
brandyscarney opened this issue Apr 8, 2016 · 6 comments
Closed

See if we can automatically inject IONIC_DIRECTIVES #6092

brandyscarney opened this issue Apr 8, 2016 · 6 comments
Assignees
Milestone

Comments

@brandyscarney
Copy link
Member

We should be able to add IONIC_DIRECTIVES so that users can create custom components without having to import them.

@mhartington
Copy link
Contributor

I don't think we should. This kind of goes against the whole import/explicit idea.
The generate command automatically includes IONIC_DIRECTIVES, so I think we could do a better job documenting that feature, or adding a section to the docs about them.

@brandyscarney
Copy link
Member Author

It was something @adamdbradley mentioned adding the other day. I think it's confusing that we do it for them in @App and @Page and then they have to figure out what they're missing when the styles don't work in their @Component.

@xeoneux
Copy link

xeoneux commented Apr 9, 2016

As a beginner to Ionic 2 and Angular 2, I spent a fair amount of time wondering why my Angular component wasn't playing nice with Ionic. At first I thought it was about wrapping the whole component in an <ion-content> or changing @Component to something else like @IonicComponent, but only after a substantial amount of time I understood the whole concept of DI through it and why IONIC_DIRECTIVES are important. Hope that helps! 😄

@frederikschubert
Copy link

You could also add the directives to the PLATFORM_DIRECTIVES DI token during bootstrap. This way they would be available in all components.

@adamdbradley
Copy link
Contributor

Thanks @frederikschubert, we did exactly that

@brandyscarney brandyscarney added this to the 2.0.0-beta.5 milestone Apr 18, 2016
@adamdbradley adamdbradley self-assigned this Apr 19, 2016
@luchillo17
Copy link
Contributor

luchillo17 commented Apr 27, 2016

@adamdbradley I would have liked to have the auto provide sooner, i had to use something like this for NorificatorComponent (ugly as hell):

// Components
import {BusyComponent, BusyCtrl, NotificatorComponent} from './components/components'
@App({
  templateUrl: 'build/app.html',
  providers: [
    BusyCtrl,
    provide(PLATFORM_DIRECTIVES, {useValue: [NotificatorComponent], multi: true})
  ],
  directives: [BusyComponent]
})

I guess now i can just stick it inside the directives array and it will be global now, right?

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants