至于多重选择'云:
https://material.angular.io/components/select/overview
HTML
class Rectangle{
int i;
int j;
Rectangle(){
i=k;//xcoor
j=l;//ycoor
}
void display(){
fill(0);
rect(i,j,sizeOfRect,sizeOfRect);
}
}
TS 从' @ angular / core'中导入{Component}; 从' @ angular / forms';
导入{FormControl}<mat-form-field>
<mat-select placeholder="Toppings" [formControl]="toppings" multiple>
<mat-option *ngFor="let topping of toppingList" [value]="topping">{{topping}}</mat-option>
</mat-select>
</mat-form-field>
有没有办法预先检查&#39;盒子里面有“额外的奶酪&#39;”,“意大利辣香肠”等?
答案 0 :(得分:2)
只需使用您希望在开始时检查的值数组定义您的浇头:
toppings = new FormControl(['Extra cheese', 'Pepperoni']);
toppingList = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
答案 1 :(得分:0)
试试这个:
toppingList = ['Extra cheese','Mushroom','Onion','Pepperoni','Sausage','Tomato'];
toppings = new FormControl(this.toppingList);