的实际问题是,我的角度完全不HTML变量忽略双括号
工作,如果你要测试的这款做到这一点:
import { Component, OnInit} from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
ngOnInit() {
console.log('test');
}
}
////////// ///////////////////////////////
/////////////// //////////////////////////
//////////////////// /////////////////////
/////////////////////
我是试图创建一个名称和值彼此不同的下拉列表。在Visual Studio 2015在括号 “> {{directionOption.name}} <” 被示出灰色作为纯文本
<select [(ngModel)]="direction">
<option *ngFor="#directionOption of directionOptions" [value]="directionOption.value">{{directionOption.name}}</option>
</select>
相同的结果
<select [(ngModel)]="direction">
<option *ngFor="let directionOption of directionOptions" [value]="directionOption.value">{{directionOption.name}}</option>
</select>
export class AppComponent implements OnInit {
direction: any = { 'Left': 'L' };
directionOptions: any = [{ name: 'Left', value: 'L' }, { name: 'Right', value: 'R' }, { name: 'None', value: 'N' }];
}
浏览器F12内的当前结果
<option *ngfor="#directionOption of directionOptions" [value]="directionOption.value">{{directionOption.name}}</option>
'directionOptions'没有一个'name' –
是。 @GünterZöchbauer是正确的。 – micronyks
我缺少哪个名字@GünterZöchbauer – Kapein