Html 选择一个producttype,然后在另一个列表中显示我选择的产品的数据。打字稿
我有一些从ws获得的web方法。另外,我有一个web方法可以获取产品类型。我想选择一种产品类型,例如,我选择产品类型传感器,当我选择这个时,我想以其他形式显示我的所有传感器列表 我的代码ts,用于获取我的所有数据:Html 选择一个producttype,然后在另一个列表中显示我选择的产品的数据。打字稿,html,angular,typescript,Html,Angular,Typescript,我有一些从ws获得的web方法。另外,我有一个web方法可以获取产品类型。我想选择一种产品类型,例如,我选择产品类型传感器,当我选择这个时,我想以其他形式显示我的所有传感器列表 我的代码ts,用于获取我的所有数据: ngOnInit() { this.ws.getAllProductType().subscribe( producttype => { this.producttype = producttype.map((producttypee)
ngOnInit() {
this.ws.getAllProductType().subscribe(
producttype => {
this.producttype = producttype.map((producttypee) => {
return new ProductType(producttypee); // Return all product Type
});
}
);
this.ws.getAllSensor().subscribe(
sensor=> {
this.sensor= sensor; // all sensor
}
)
this.gs.getAllGpss().subscribe(
gps => {
this.gps = gps; //all gps
}
)}
我的html代码
<div class="input-field col s12">
<select formControlName="product_type_id" id="product_type_id" materialize="material_select" [materializeSelectOptions]="producttype">
<option value="" disabled selected>ProductType*</option>
<option *ngFor="let item of producttype; let i=index;" [value]="item.product_type_id">{{item.product_type_name}}</option>
</select>
</div>
产品类型*
{{item.product_type_name}
像这个html代码一样,我想显示传感器和gps。在productType中选择传感器时,在其他列表中我要显示传感器,在productType中选择GPS时,在其他列表中我要显示GPS
你能给我一些建议吗?HTML代码是这样的 它可能有任何语法错误,因为您没有向我提供您的代码plnkr样本
<!-- Lets say 1 is for Sensor -->
<div *ngIf="producttype.product_type_id == '1'">
<ul>
<li *ngFor="let s of sensor">
{{s.name}}
</li>
</ul>
</div>
<!-- Lets say 2 is for GPS -->
<div *ngIf="producttype.product_type_id == '2'">
<ul>
<li *ngFor="let g of gps">
{{g.name}}
</li>
</ul>
</div>
-
{{s.name}}
-
{{g.name}}
您可以在