当用户在提示对话框中输入正确的字符串时,我希望按钮显示。但是目前,回调函数被正确调用,但是为了使按钮可见,我必须调用" checkPassword"两次。
模板:
<div class="form-group" ng-if="showEdit">
<input type="submit" class="btn btn-primary pull-right" value="Add New">
</div>
<button type='button' class='btn btn-primary' ng-click="checkPassword()">Edit</`button>
脚本
$scope.checkPassword = function() {
bootbox.prompt("This is the default prompt!", function(result){
if(result == "password"){
$scope.showEdit = true;
}
else{
bootbox.alert("Wrong password");
}
});
}