CoreTemplatePack icon indicating copy to clipboard operation
CoreTemplatePack copied to clipboard

TemplateUrl not working

Open ovaismehboob opened this issue 8 years ago • 1 comments

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:

  1. I have also added the "angular2-template-loader" as dev dependency in package.json.
  2. 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'] } ] }

ovaismehboob avatar Nov 19 '16 07:11 ovaismehboob

have you tried replacing :

templateUrl: 'YourPath'

with

template: require('../YourPath')

?

peterdobson avatar Jan 04 '17 22:01 peterdobson