Closed onecib closed 7 years ago
@xcuben try this:
<ui-switch [(ngModel)]="enable" (change)="onChange()"></ui-switch>
@Component({
selector: 'app',
template: require('./app.html')
})
export class AppComponent {
enable: boolean = false;
onChange() {
if(!this.enable && !confirm('sure to change?')){
setTimeout(() => {
this.enable = false;
});
}
}
}
@yuyang041060120 : I can't apply the ngModel on ui-switch tag . because for that i would need ngForm and i totally dont need it also. is there any other way to do it ?
@xcuben so you just use onChange?
@yuyang041060120 I tried it , it is working in background (the value of enable is changing only if the user confirms) but the switch-button is switching without considering the user-response
@xcuben I' m sorry you can't prevent the default switch behavior. But you can change it from checked to unchecked state when the user denies.
Hi there, right now i am using ui-switch module in my angular 2 application. and would like to put a confirmation message (alert) while deactivating the ui-switch-boxes: ----> first case , the user confirms , and the ui-switch-box becomes active ----> second case, the user denies , and the ui-switch-case must stay inactive. is there any implementation for such an issue ? if no , is there any possibility to provoke the click event (or the change event ) twice ?
cheers Othman