CoreTemplatePack
CoreTemplatePack copied to clipboard
TemplateUrl not working
Hi,
I am using ASP.NET Core + Angular 2 template. The problem is with the TemplateURL which is not working with any URL. In my scenario I want to route it to the MVC controller and wanted to load the about page of Home controller.
Below is the exception. Exception: Call to Node module failed with error: Error: No ResourceLoader implementation has been provided. Can't read the url "Home/About"
Here is my sample about.component.ts
import {Component} from '@angular/core'; import { platformUniversalDynamic } from 'angular2-universal'; @Component({ selector: 'about', templateUrl: 'Home/About' })
export class AboutComponent { message: string = 'Hello World';
Side notes:
- I have also added the "angular2-template-loader" as dev dependency in package.json.
- Here is my module configuration in webpack.json
module: { loaders: [ { test: /.ts$/, loaders: ['awesome-typescript-loader', 'angular2-template-loader?keepUrl=true'], exclude: [/.(spec|e2e).ts$/] }, /* Embed files. / { test: /.(html|css)$/, loader: 'raw-loader', exclude: /.async.(html|css)$/ }, / Async loading. */ { test: /.async.(html|css)$/, loaders: ['file?name=[name].[hash].[ext]', 'extract'] } ] }
have you tried replacing :
templateUrl: 'YourPath'
with
template: require('../YourPath')
?