angularjs – 错误:找不到MyAppComponent的模板
发布时间:2020-12-17 06:58:27 所属栏目:安全 来源:网络整理
导读:我遵循了 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} fro
我遵循了
Angular 2 Quickstart指南但得到以下错误:
这是相关代码: 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所示的情况. 那么为什么Quickstart代码会抛出错误,什么是正确的修复? 解决方法
我想你需要检查一下
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); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |