我遵循了
Angular 2 Quickstart指南但得到以下错误:
Error during instantiation of Token(AppView)!. ORIGINAL ERROR: Error:
No template found for MyAppComponent
这是相关代码:
import {Component,View} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser' // Note I've changed Template to View here as I think it is a typo .... @View({ template: '<h1>Hello {{ name }}</h1>' }) ....
按照Duncan Booth在http://blog.ionic.io/angular-2-series-introduction/的建议,我做了以下更改,一切正常:
import {Component,Template} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; .... @Template({ inline: "<h1>Hello {{ name }}</h1>" }) ....
但是,yesimahuman在同一个链接上的评论中提到“视图是新语法”,似乎就是Angular 2 Step by Step Guide Plunker所示的情况.
解决方法
我想你需要检查一下
import {Component,Template,bootstrap} from 'angular2/angular2'; @Component({ selector: 'my-app' }) @Template({ inline: '<h1>Hello {{ name }}</h2>' }) class MyAppComponent { constructor() { this.name = 'Alice'; } } bootstrap(MyAppComponent);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。