我正在尝试学习nodejs。我有一个简单的应用程序,我在 app.component.ts
options
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
options = ["Option1", "Option2"];
}
我正在尝试将选项公开为下拉列表 app.component.html
<div style="text-align:center">
<h1>
{{options}}!
<select name="repeatSelect" id="repeatSelect" ng-model="app-root">
<option ng-repeat="option in options" value="{{option}}">{{option}}</option>
</select>
</h1>
由于某种原因,选择框没有被填充。如果我打印选项,我可以清楚地看到它打印得很好。 这是截图
最佳答案
您应该使用*ngFor 。因为您使用的是 Angular 4。Angular 2/4/5 中没有 ng-repeat 指令。
<option *ngFor="let option of options" value="{{option}}">{{option}}</option>
关于javascript - Angular 选择不填充选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47279513/