Pet*_*IRT 7 angular2-template angular
我按照angular.io入门项目使用种子结构.到目前为止一切都还可以.
现在我想更改顶部组件以从分离的文件中获取视图,然后我遇到了麻烦.工作代码是:
import {Component, View} from 'angular2/core';
@Component({
selector: 'my-app',
template: '<h1>Angular2</h1>',
directives: []
})
export class AppComponent {
constructor() {
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将模板更改为templateUrl,如下所示:
templateUrl: 'app.component.html',
我在这个文件中的代码与以前完全相同
<h1>Angular2</h1>
工作似乎很明显,但事实并非如此.它没有吐出错误,但除了"loading ...."消息之外,它没有显示任何内容,如在入门演示中那样
谢谢你的帮助
彼得
bFu*_*unc 23
在@Component装饰器中添加moduleId:module.id.如果您没有,那么Angular 2将在根级别查找您的文件.
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
moduleId: module.id,
templateUrl: 'app.component.html'
})
export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)
看看这篇文章
归档时间: |
|
查看次数: |
14737 次 |
最近记录: |