, Angular 2 rc.6
1 typescript 2, .
npm install typescript@2.0.2
2 system tsconfig.json
"compilerOptions": {
"target": "ES5",
"module": "system",
...
}
3 . , ; ...
@Component({
module: moduleId,
templateUrl: './app.component.html',
})
...
@Component({
module: __moduleName,
templateUrl: './app.component.html',
})
4 typescript, __moduleName . , (.d.ts) , .
custom.typings.d.ts
declare var __moduleName: string;
declare module "*!text"
5 , typescript : main.ts
6 , . systemjs-plugin-:
npm install systemjs-plugin-text@0.0.9
7 systemjs.config.js
System.config({
map:{
'app': 'app',
'@angular': 'node_modules/@angular',
//'text' map is used to import files as raw strings
text: 'node_modules/systemjs-plugin-text/text.js'
}
});
8
// this line should raise no error if steps 4 & 5 were completed correctly
import htmlTemplate from './app.component.html!text';
console.log(htmlTemplate); //will print the file as a string in console
@Component({
moduleId: __moduleName,
template: htmlTemplate, //success!!
})
! , systemjs-builder , .