Unable to read URL error for angular2 dynamic components with Url pattern

Tried changing soultion from here . It works fine, but if you change the template to templateUrl in the component that needs to be dynamically loaded, you will get the error message: "No implementation of ResourceLoader was provided. Unable to read URL ...".

@Component({
    selector: 'string-editor',
    templateUrl: 'app/parts/string.html', //using template URL instead of inline template here
})
export class StringEditor { ... }

Live example on plunker . Any ideas how to fix this?

+4
source share
1 answer

Do not use COMPILER_PROVIDERSbecause it overrides ResourceLoader.

Compiler ( RuntimeCompiler):

@Inject(Compiler) protected compiler: Compiler

ApplicationModule :

imports: [ 
    ApplicationModule,
    BrowserModule,
    DynamicModule.forRoot() // singletons
],

Plunker

+3

Source: https://habr.com/ru/post/1655608/


All Articles