Okay, so I have a constant variables in the _Layout.cshtml of ASP.Net SPA project and I would to pass them so that Angular will have access to those.
How can I do t
It depends on what you want exactly to do but I see two possibilities:
This constant needs to be passed when importing your main module. Whereas it's not possible to do this on the import
itself. You can import a function and call it with parameters.
Here is a sample of the main module that bootstraps your application:
import {bootstrap} from '...';
import {provide} from '...';
import {AppComponent} from '...';
export function main(lenderValues) {
bootstrap(AppComponent, [
provide('lenderValues', { useValue: lenderValues })
]);
}
Then you can import it from your HTML main page like this:
Your lenderValues
can be then injected in all elements like a component:
@Component({
(...)
})
export class SomeComponent {
constructor(@Inject('lenderValues') lenderValues) {
}
}
my-rite-ui
elementYou can specify a parameter at this level but it can't be evaluated. So it's a bit more tedious since you need to serialize it as string with JSON.stringify
, gets the element in your component from its corresponding ElementRef
and deserialize it using JSON.parse
.
Then you can add the data as a provider.