小编ald*_*ldo的帖子

使用ngModel动态修改角度mat-checkbox

我有一个类Offer,它有一个属性"units"作为对象数组.

export class Offer {
   public propertyA: string;
   public propertyB: string;
   public units: Unit[];
}

export class Unit {    
    public code: string,
    public name: string,
    public checked: boolean
}
Run Code Online (Sandbox Code Playgroud)

我使用的是Angular2,这些单位必须是用户可以选择的复选框.我也使用棱角分明的材料.

html代码如下:

<div *ngFor="let unit of model.units; let i=index">
  <mat-checkbox [(ngModel)]="model.units[i].checked"
    id="units[{{i}}]" name="units[{{i}}]">
       {{ unit.name }}
  </mat-checkbox>                        
</div>    
Run Code Online (Sandbox Code Playgroud)

units属性使用以下方式加载:

this.model.units.push(new Unit("code1","name1", false));
this.model.units.push(new Unit("code2","name2", false));
this.model.units.push(new Unit("code3","name3", false));
Run Code Online (Sandbox Code Playgroud)

当我发送表单时,checked属性不包含选中的值.

我究竟做错了什么??

typescript angular-material angular

9
推荐指数
3
解决办法
2万
查看次数

ng build --prod --localize 时更改角度基本 href

情况

我创建了一个具有国际化(i18n)的 Angular 应用程序。我想在子域中托管不同版本,例如:

  • en.myexample.com
  • es.myexample.com

问题

当我使用命令时, src/app/index.hml 中的ng build --prod --localize标签基本 href添加了语言,例如:

  • <base href="/en/">
  • <base href="/es/">

我想要的是

生成每个版本<base href="/">

localization angular-i18n angular

3
推荐指数
1
解决办法
2190
查看次数