Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';t访问值Angular2_Javascript_Angular_Ecmascript 6 - Fatal编程技术网

Javascript Can';t访问值Angular2

Javascript 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)

我正试图用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);
你好_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` -->