如何检查在 angular2 中是否选择了两个下拉列表,如果是,则调用某种方法?
How to check that two dropdown lists is selected in angular2 and if it's true invoke some method?
我有一个下拉列表,我想检查用户是否在两个列表中都选择了值,以及是否都选择了将从每个列表中接收两个值的调用方法。
如果您提供 html 和组件代码,我们可以改进逻辑。
两个复选框都有两个布尔值。
private val1Changed= false;
private val2Changed = false;
public val1ChangeHandler(){
this.val1Changed= true;
this.performAction();
}
public val2ChangeHandler(){
this.val2Changed= true;
this.performAction();
}
public performAction(){
if(!(this.val1Changed && this.val2Changed)){
return;
}
// perform some action
// Reset values after action is successfully performed
this.val1Changed = false;
this.val2Changed = false;
}
在 HTML (change)
标签中添加 val1ChangeHandler
和 val2ChangeHandler
我有一个下拉列表,我想检查用户是否在两个列表中都选择了值,以及是否都选择了将从每个列表中接收两个值的调用方法。
如果您提供 html 和组件代码,我们可以改进逻辑。
两个复选框都有两个布尔值。
private val1Changed= false;
private val2Changed = false;
public val1ChangeHandler(){
this.val1Changed= true;
this.performAction();
}
public val2ChangeHandler(){
this.val2Changed= true;
this.performAction();
}
public performAction(){
if(!(this.val1Changed && this.val2Changed)){
return;
}
// perform some action
// Reset values after action is successfully performed
this.val1Changed = false;
this.val2Changed = false;
}
在 HTML (change)
标签中添加 val1ChangeHandler
和 val2ChangeHandler