我正在嘗試從角度值串列中顯示下拉串列。但是當我嘗試使用 ng-repeat 時出現錯誤,我無法理解是什么問題
應用程式組件.html
<h1>hi </h1>
<br><br><br>
<select>
<option ng-repeat="x in names">{{x}}</option>
</select>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
names = ["Pending", "Out for delivery", "Delivered"];
title = 'dropdownproj';
}
有人可以幫我解決這個問題嗎?這可能是一個愚蠢的錯誤,但我無法控制它。幫助!
我得到的錯誤
Property 'x' does not exist on type 'AppComponent'.
uj5u.com熱心網友回復:
嘗試這個
<select>
<option *ngFor="let x of names" [value]="x">
{{x}}
</option>
</select>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/322403.html
標籤:有角的
