我正在尝试使用Angular2和ES6启动一个项目,但我在尝试访问我的数据时遇到了问题。
index.js
import {zoneJs} from 'zone.js'
import {reflectMetadata} from 'reflect-metadata'
import {bootstrap} from 'angular2/platform/browser';
import {HelloWorld} from './hello_world';
bootstrap(HelloWorld);hello_world.js
import {Component} from 'angular2/core';
@Component({
// Declare the tag name in index.html to where the component attaches
selector: 'hello-world',
// Location of the template for this component
templateUrl: 'dist/template/hello_world.html'
})
export class HelloWorld {
yourName = ''
}hello_world.hlml
<label>Name:</label>
<!-- data-bind to the input element; store value in yourName -->
<input type="text" [(ngModel)]="yourName" placeholder="Enter a name here">
<hr>
<!-- conditionally display `yourName` -->
<h1 [hidden]="!yourName">Hello {{yourName}}!</h1>该模板在我的网页中重现,但我有以下错误
script.js:17 EXCEPTION: No value accessor for '' in [yourNames in s@2:19]发布于 2016-04-04 20:28:28
发布于 2016-04-04 20:28:44
从HTML中删除这一行,它应该会开始工作,
<!-- conditionally display `yourName` -->https://stackoverflow.com/questions/36402553
复制相似问题