You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Angular 6 introduced a new way to register providers in order to make them tree-shakable. That gives Angular the ability to remove services that are not used in the application from the final output.
To create a tree-shakable provider you need to specify the injector which injects a service in the metadata of that service. For example:
Setting the value to root ensures that the service is scoped to the root injector.
Issue
The tree-shakable providers scoped to the root injector (the above example) don't get registered in NativeScript, which results in the following error:
Error: NullInjectorError: No provider for Service!
Solution
The NativeScriptModule should be marked as root. We can do that by providing the APP_ROOT token in the metadata of that module.
What are tree-shakable providers?
Angular 6 introduced a new way to register providers in order to make them tree-shakable. That gives Angular the ability to remove services that are not used in the application from the final output.
To create a tree-shakable provider you need to specify the injector which injects a service in the metadata of that service. For example:
Setting the value to
root
ensures that the service is scoped to the root injector.Issue
The tree-shakable providers scoped to the root injector (the above example) don't get registered in NativeScript, which results in the following error:
Solution
The
NativeScriptModule
should be marked as root. We can do that by providing theAPP_ROOT
token in the metadata of that module.Demo
https://play.nativescript.org/?template=play-ng&id=tCY7bL
The text was updated successfully, but these errors were encountered: