我試圖通過ES6獲得angular2的保留,沒有打字稿。問題是我不知道如何渲染一個子組件。我有這個基礎組件,只是拿着應用程序。在那個組件中,我希望能夠渲染,比如頭部組件和頁腳組件。現在只有我的基礎組件被渲染。Angular2 + Es6。渲染子組件
我該怎麼做?
這裏是我的代碼:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<application>
<header></header>
</application>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/reflect-metadata/Reflect.js"></script>
<script src="/dist/js/app.js"></script>
</body>
app.js
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {Header} from './components/app.header';
class Base {
static get annotations() {
return [
new Component({
selector: "body",
template: '<application>base</application>'
}),
];
}
constructor() {}
}
export {Base};
bootstrap(Base);
app.header.js
import {Component} from 'angular2/core';
class Header {
static get annotations() {
return [
new Component({
selector: 'header',
template: '<h1>header</h1>'
}),
];
}
constructor() {}
}
export {Header};
我還沒有得到這個權利。任何人有解決方案? – user2952238
你可以將你的代碼添加到github倉庫或者倉庫中,這樣我們可以幫你嗎? –