angular - Can I use a service which is used by the imported component? -
i've started developing via angular2 , liked it. today faced such problem: have reusable component of alerts uses it's own service business logic in it.
can use same service put data tests in component importing reusable component in it? okay? reusable component see data in service imported service in such way?
thank answers. luck!
it depends want :
- if want service same(singleton) need inject service in root component or in bootstrap, should fine.
- if want service alerts component , different data component, inject service in both, should fine. https://angular.io/docs/ts/latest/guide/hierarchical-dependency-injection.html
Comments
Post a Comment