Reputation: 7856
I have the following select (PUG)
select.custom-select(name='category', formControlName='category')
option(*ngFor="let category of essentials.categories") {{category.name}}
This code works but I would like to bind the form control to category.code
such as:
select.custom-select(name='category', formControlName='category')
option(*ngFor="let category of essentials.categories" [ngValue]="category.code") {{category.name}}
With the above code, I'm getting an error (Can't bind to 'ngFor' since it isn't a known property of 'option'
). I also tried with [value]="category.code"
without success...
Edit: I'm using Angular 2 RC7
Upvotes: 1
Views: 424
Reputation: 8290
Try escaping *ngFor
by enclosing it with quotes (remember about [ngValue]
as well.
select.custom-select(name='category', formControlName='category')
option("*ngFor"="let category of essentials.categories", "[ngValue]"="category.code") {{category.name}}
Upvotes: 1