我有一个按钮:
$scope.deleteCompany = function(id){
console.log(id);
}
我也有角度函数:
1
当我在确认控制台输出时点击取消时:
1
当我在确认控制台输出时单击确定时:
dBuilder.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) {
// it might be a good idea to insert a trace
// logging here that you are ignoring publicId/systemId
return new InputSource(new StringReader("")); // Returns a valid dummy source
}
});
我希望角度代码在" Ok"被按下但不是当"取消"被按下了。
JSFiddle示例:ButtonCommandNew.RaiseCanExecuteChanged
答案 0 :(得分:5)
将confirm
扔进$scope.deleteCompany()
功能:
function MyCtrl($scope) {
$scope.deleteCompany = function(id) {
if (confirm('This will permernently delete the entity\nAre you sure you want to delete this post?')) {
$scope.name = id;
// delete the stuff.
}
}
}
将其从内联HTML中删除:
<div ng-controller="MyCtrl">
<button ng-click="deleteCompany('1')" class="btn btn-danger">
<span class="glyphicon glyphicon-trash"></span>
</button>
<button ng-click="deleteCompany('2')" class="btn btn-danger">
<span class="glyphicon glyphicon-trash"></span>
</button>
Hello, {{name}}!
</div>
答案 1 :(得分:3)
为什么不将confirm
放在deleteCompany
方法中?
$scope.deleteCompany = function(id) {
if (!confirm("Delete company?"))
return;
console.log(id);
}