So I've upgrade from RC1 to the final release of Angular2. I've done a lot of adjustments but every time I injected RuntimeCompiler
on my AppComponent
, this error occurs.
I have no idea what is happening here and haven't seen the answers for the web regarding this issue. Any help would be appreciated, anyway here is my AppComponent for reference.
import { Component } from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
import { RuntimeCompiler } from '@angular/compiler';
@Component({
selector: 'content',
template: '<router-outlet></router-outlet>'
})
export class AppComponent {
constructor(
private location: Location,
private router: Router,
private runtimeCompiler: RuntimeCompiler
) {;
if (localStorage.getItem('id_token') == undefined) {
if (location.path().toLowerCase().startsWith('/login')) {
// LET IT BE
} else {
router.navigate(['login']);
}
runtimeCompiler.clearCache();
} else {
router.navigate(['menu']);
}
}
}
Thank you in advance.
I would say, that you should add the providers set to the app module:
import { COMPILER_PROVIDERS } from "@angular/compiler";
...
@NgModule({
imports: [
...
BrowserModule
],
declarations: [ ... ],
bootstrap: [ ... ],
providers: [
COMPILER_PROVIDERS
],
})
export class AppModule { }
This set COMPILER_PROVIDERS
of providers contains all what is needed by RuntimeCompiler
. There is an example
with working plunker
using that piece of code How can I use/create dynamic template to compile dynamic Component with Angular 2.0? and some more details...