【发布时间】:2016-10-20 19:30:42
【问题描述】:
我正在尝试根据另一个选择的命名公司过滤我选择的命名分支的值,但是当我尝试更新分支数组的值时出现错误:
试图区分 [object Object]
我的服务:
getCCBs() {
return this._http.get('CustomerCompanyBranches/GetCCBs').map(res => res.json());
}
我的组件:
export class CompanyComponent {
companies: CustomerCompany[];
branches: any;
constructor(private _ser: DemoService) {}
getComps() {
this._ser.getCCs().subscribe(res => this.companies = res);
}
getCBran() {
this._ser.getCCBs().subscribe(res => this.branches = res);
}
onSelect(customercompanyname) {
console.log(customercompanyname);
this.branches = this._ser.getCCBs().subscribe(res => res.find(br => br.CustomerCompanyBranchName === customercompanyname));
}
ngOnInit() {
this.getComps();
this.getCBran();
}
}
我的html:
<label>Company:</label>
<select (change)="onSelect(t.value)" #t>
<option value="0">--Select--</option>
<option *ngFor="#c of companies" value={{c.CustomerCompanyName}}>{{c.CustomerCompanyName}}</option>
</select>
{{t.value}}
<br /><br />
<div >
<label>Branch:</label>
<select>
<option *ngFor="#b of branches">
{{b.CustomerCompanyBranchAddress}}
</option>
</select>
</div>
【问题讨论】:
标签: html asp.net-mvc angular typescript