Angular2 component without view annotation

半腔热情 提交于 2019-12-08 08:45:32

You can do something similar, that is probably what you want. Take this example:

import {Component, View, bootstrap} from "angular2/angular2";

@Component({
    selector: "app"
})
@View({
    template:  "<content></content>"
})
export class App {
    public name: string;

    constructor() {
        this.name = "MyName";
    }
}
bootstrap(App);

The template has a special content <content></content> that represents the ngTransclude directive. This will allow you to add content inside the app tag:

<app>
    <h1>Hello World</h1>
</app> 

Unfortunately this is still poorly undocumented and changing so it's hard to tell about the actual limitations or even if this will remain like this.

Regards.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!