Javascript Can';t访问值Angular2
我正试图用Angular2和ES6启动一个项目,但我在尝试访问我的数据时遇到了一个问题 index.jsJavascript Can';t访问值Angular2,javascript,angular,ecmascript-6,Javascript,Angular,Ecmascript 6,我正试图用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)
import {zoneJs} from 'zone.js'
import {reflectMetadata} from 'reflect-metadata'
import {bootstrap} from 'angular2/platform/browser';
import {HelloWorld} from './hello_world';
bootstrap(HelloWorld);
你好_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 = ''
}
你好_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>
似乎对我来说很好-> 我只需要把背面的记号去掉就行了
<!-- conditionally display `yourName` -->
从HTML中删除这一行,它将开始工作
<!-- conditionally display `yourName` -->
只是因为一个丑陋的问题
<!-- conditionally display `yourName` -->