Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using relative path for templateUrl in Component with SystemJS

Tags:

I'm trying to use relative path when defining templateUrl in angular2 component, as described here: http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/

@Component({     selector: 'login-app',     moduleId: module.id,     templateUrl: './app.html' }) 

although I keep getting:

ERROR: module is not defined

I am using --m commonjs in TypeScripy compile settings.

How to make it work?

like image 577
Sagi Avatar asked Jan 01 '16 12:01

Sagi


1 Answers

This simply doesn't seem to work for me. I can see in the Github repo for Angular 2 that the feature was supposedly added in early December, but it doesn't function at all best I can tell.

The docs have not been updated to reflect it, and it's still missing proper tests from what I can tell.

Update:

Here's part of what's going on. This requires a CommonJS specific feature to work, so you have to have that module system in use in your tsconfig.json file.

On top of that, there's an issue when using SystemJS because of the way it bundles everything into the root.

Basically there seem to be a lot of restrictions on being able to use this new feature.

like image 199
Michael Oryl Avatar answered Sep 30 '22 07:09

Michael Oryl