Javascript 角度选择不填充选项
我正在努力学习nodejs。我有一个简单的应用程序,我在Javascript 角度选择不填充选项,javascript,angularjs,node.js,bootstrap-4,Javascript,Angularjs,Node.js,Bootstrap 4,我正在努力学习nodejs。我有一个简单的应用程序,我在app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app';
app.component.ts
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>
{{options}}!
{{option}}
由于某些原因,选择框未填充。如果我打印选项,我可以清楚地看到它打印得很好。
这是截图
您应该使用。因为你用的是角度4。angular 2/4/5中没有ng repeat指令
<option *ngFor="let option of options" value="{{option}}">{{option}}</option>
{{option}
试试看
{{option}}
我认为你混合了angularjs和angular 4,你是对的,但是没有选项中的**let**options
它不起作用,谢谢你把明显的东西指向新手。
<div style="text-align:center">
<h1>
<select name="repeatSelect" id="repeatSelect" >
<option *ngFor="let option of options;" value="{{option}}">{{option}}</option>
</select>
</h1>