dependency injection - Angular 2 injectable AppSettings Class -


i'm using angular 2 inside of asp.net core application, isn't important issue. part of current task configuration values server angular application.

i have settings flowing through point writing 1 setting layout so:

<script>     var base_web_api_url = '@appsettings.baseurls.api'; </script> 

and working, have verified looking @ markup. now, want make appsettings class can inject via di services , components need it. here have far:

import { injectable } '@angular/core';  @injectable() export class appsettings {     public base_web_api_url: string = window['base_web_api_url']; } 

very simple , straight forward , should allow me inject server variables. however, error when try use it.

error: uncaught (in promise): error: no provider appsettings!

so, thought problem wasn't listed in imports in app module. added error:

error: unexpected value 'appsettings' imported module 'appmodule'

so, googling error lead me post saying maybe needed in bootstrap section, tried next new error message.

error: no directive annotation found on appsettings

i'm green angular 2, these errors throwing me off. thoughts on doing wrong?

thank you

put injectables module's providers metadata, not imports.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -