Ionic framework 是否有方法读取离子段值,将其传递给离子工厂,以根据开关箱运行不同的功能?
我现在有一个带两个开关盒的离子段。这就是管理与市场。但是,我想包括一个FAB按钮,根据用户所处的开关柜运行不同的功能 我已经试过把晶圆厂放在SwitchCase选项中,但是晶圆厂似乎是随着页面滚动而不是粘住 fab应针对不同的开关情况运行不同的功能 //段的代码Ionic framework 是否有方法读取离子段值,将其传递给离子工厂,以根据开关箱运行不同的功能?,ionic-framework,ionic3,Ionic Framework,Ionic3,我现在有一个带两个开关盒的离子段。这就是管理与市场。但是,我想包括一个FAB按钮,根据用户所处的开关柜运行不同的功能 我已经试过把晶圆厂放在SwitchCase选项中,但是晶圆厂似乎是随着页面滚动而不是粘住 fab应针对不同的开关情况运行不同的功能 //段的代码 <ion-header> <ion-segment [(ngModel)]="options" color="grey"> <ion-segment-butt
<ion-header>
<ion-segment [(ngModel)]="options" color="grey">
<ion-segment-button value="Management">
Management
</ion-segment-button>
<ion-segment-button value="Market">
Crop Market
</ion-segment-button>
</ion-segment>
</ion-header>
//CODE FOR IMPLEMENTATION OF THE SEGMENT
<ion-content>
<div [ngSwitch]="options" class="management-class"> //FIRST SWITCH CASE
<div *ngSwitchCase="'Management'">
<//MANAGEMENT CONTENT FOR THIS SWITCH CASE>
</div>
</div>
<div [ngSwitch]="options" class="management-class">//SECOND SWITCH CASE
<div *ngSwitchCase="'Market'">
<//MARKET CONTENT FOR THIS SWITCH CASE>
</div>
</div>
//This is the ion-fab button to that switches functions based on the users current switch case.
<ion-fab right bottom>
<button *ngIf="this.options=Market" ion-fab (click)="addToMarket()" color="primary" mini><img src="assets/imgs/add1.png"></button>
<button *ngIf="this.options=Management" ion-fab (click)="plantNew()" color="primary" mini><img src="assets/imgs/add1.png"></button>
</ion-fab>
</ion-content>
管理层
作物市场
//执行该部分的代码
//第一开关箱
//第二开关箱
//这是ion fab按钮,用于根据用户当前的开关情况切换功能。
在您的细分市场上使用ionChange事件,如:
<ion-segment (ionChange)="segmentChanged($event)">
<ion-segment-button value="friends">
<ion-label>Friends</ion-label>
</ion-segment-button>
<ion-segment-button value="enemies">
<ion-label>Enemies</ion-label>
</ion-segment-button>
</ion-segment>
改变你的价值观:
<ion-fab right bottom>
<button *ngIf="segmentValue == 'friends'" ion-fab (click)="addToMarket()" color="primary" mini><img src="assets/imgs/add1.png"></button>
<button *ngIf="segmentValue == 'enemies'" ion-fab (click)="plantNew()" color="primary" mini><img src="assets/imgs/add1.png"></button>
</ion-fab>
您可以使用ionChange功能<代码>
<ion-fab right bottom>
<button *ngIf="segmentValue == 'friends'" ion-fab (click)="addToMarket()" color="primary" mini><img src="assets/imgs/add1.png"></button>
<button *ngIf="segmentValue == 'enemies'" ion-fab (click)="plantNew()" color="primary" mini><img src="assets/imgs/add1.png"></button>
</ion-fab>