I am using angular js for my application in which i am having a scenario of if the type === 'await_otp' then display two buttons(resend otp and cancel button) in the div else if the type === 'submitted' then show cancel button.If none of the above conditions met then don't display buttons.
Earlier i have used two seperate buttons for each condtions and displayed the button.But i would like to use a single function to handle this.
Can anyone tell me how to do it.
<ion-footer-bar style="height:auto">
<div ng-if="vm.canShowCancel()" class="bar bar-footer bar-assertive" style="position: absolute;" ng-click="vm.cancelApplication(vm.applicationDetails.id)">
<div class="title" translate>CANCELAPPLICATION</div>
</div>
<div class="bar" ng-if="!vm.canShowCancel()" style="position:absolute; bottom:0;text-align:center;padding:0 !important" >
<button style="min-width:50%; border-radius:0px" class="button button-balanced" ng-click="vm.resendOtp(vm.applicationDetails.id)"
translate>RESEND</button>
<button style="min-width:50%; border-radius:0px" class="button button-assertive" ng-click="vm.cancelApplication(vm.applicationDetails.id)" translate>CANCELAPPLICATION</button>
</div>
</ion-footer-bar>
Controller:
function canShowCancel () {
if (vm.applicationDetails && (vm.applicationDetails.state === 'submitted' || vm.applicationDetails.state === 'await_otp_verif')) {
return true;
}
}
Functions which i have used earlier:
function isAwaitingOtp () {
return vm.applicationDetails && vm.applicationDetails.state === 'await_otp_verif';
}
function isSubmitted () {
return vm.applicationDetails && vm.applicationDetails.state === 'submitted';
}