i am trying to display a dropdownlist from a list of values in angular. But as I try to use ng-repeat i get an error and i am unable to understand whats the problem
app.component.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';
}
can someone help me out with this. It might be a silly mistake but i cant get a hold of it. Help!
error i get
Property 'x' does not exist on type 'AppComponent'.
CodePudding user response:
try this
<select>
<option *ngFor="let x of names" [value]="x">
{{x}}
</option>
</select>