【发布时间】:2016-05-07 16:17:31
【问题描述】:
我希望有人可以为我解决这个问题。我假设对此有一个简单的答案。但如果它在互联网上我似乎无法找到它。请记住,我很少有 Angular 1 的经验,所以如果我遗漏了一些明显的东西,我深表歉意。
我已经看到了以下在 Angular 2 中创建模板的示例。
//Example 1
@Component({
selector: 'my-app'
})
@View({
template : '<p></p>'
})
据我了解,上面的例子和这个是一样的。
// Example 2
@Component({
selector: 'my-app',
template: '<p></p>'
})
根据这个https://angular.io/docs/ts/latest/api/core/View-decorator.html和这个@Directive v/s @Component in angular2
那么有什么好的理由来创建像第一个示例和第二个示例一样的模板,其中@View 似乎是通过@Component 使用“模板:”隐式设置的?
【问题讨论】:
标签: javascript angular