ngx-tabs-libdemo | NON PRODUCTION READY - Repository to demonstrate | Frontend Framework library
kandi X-RAY | ngx-tabs-libdemo Summary
kandi X-RAY | ngx-tabs-libdemo Summary
NON PRODUCTION READY - Repository to demonstrate Angular libraries
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ngx-tabs-libdemo
ngx-tabs-libdemo Key Features
ngx-tabs-libdemo Examples and Code Snippets
Community Discussions
Trending Discussions on ngx-tabs-libdemo
QUESTION
I'm creating an angular library for components shared across multiple apps. I'm running into trouble when using a service from inside the library inside a component from the library.
The service is intended to be injected at the root of the app (not library) and can be used throughout the app.
In this scenario, we're looking at the ToastService
and UIToastComponent
. The UIToastComponent
is exported from the UIToastModule
.
The app then imports the UIToastModule
inside the application's AppModule
, where is also provides the ToastService
.
The tag sits in the application's
app.component.html
file.
The idea being, in any component inside the application, the developer can inject ToastService
and call this.toastService.success('Great Success!')
, which is picked up by the UIToastComponent
and displays the toast.
The constructor
for the UIToastComponent
can't seem to pick up the service, and at runtime I the following error:
ANSWER
Answered 2018-Jan-15 at 17:17You need to implement forRoot
in the module that defines your package, provide the service there and import the module in AppModule
with MyModule.forRoot()
See also https://angular.io/guide/ngmodule-faq#what-is-the-forroot-method
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ngx-tabs-libdemo
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page