1

In Angular 2, to support templates with a relative path, you have to set moduleId: module.id inside the component decorator. (see here)

The "problem" is it requires compiling the project in commonjs format. How should you do it with other modules format ? (like systemjs)

1

1 Answer 1

1

This is a duplicate: Using relative path for templateUrl in Angular2 Component with SystemJS

Anyway, in a nutshell:

SystemJS supports CommonJS, so you can just set it to commonjs. However module.id, is not recognized by TypeScript, but it does exist. so you need to add a declaration file:

tsconfig.json

"module": "commonjs",

typings.d.ts

declare var module: { id: string };

It might be a good idea to take a close look at how angular-cli generates projects.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.