0
如何根据存储在result
中的值显示html文件中的按钮?如何根据各种值显示按钮
page1.ts
class page1 {
let result: string; //possible values of result can be 'additon',
//'multiply','divide'.
constructor(public serviceClass : ServiceClass){
this.initialzie();
}
additon(){
this.result = 'addition';
}
modulus(){
//logic for this function.
}
initialize(){
this.result = this.serviceClass.someFunction();
}
}
page1.html
//headers and title already implemented.
// buttons to implement now.
//**condition**: The below button is only shown on the basis of the value
//populated in the result variable in .ts class.
<div> //if result = 'multiply, 'divide' then show this button.How to
//implement this?
<button ion-button (click)="addition()">ADD ME</button>
</div>
<div> //if result = 'addition' then show this button.How to implement this?
<button ion-button (click)="modulus()">Modulus</button>
</div>
当我点击我添加按钮结果的价值得到'除了按钮并不代替'Modulus' – Aditya
其中是你的加法函数 –
当我点击加法()然后以某种方式更新'result = addition'的值,所以当值更改为'加法'时,按钮应该改变为'模数这是我需要实现的必需逻辑。 – Aditya