我有形式模式弹出up.i使用指令打开模态弹出复位形式模态弹出关闭按钮(X)在Angularjs
mymodule.directive('modalDialogSite', function() {
return {
restrict: 'E',
scope: {
show: '='
},
replace: true, // Replace with the template below
transclude: true, // we want to insert custom content inside the directive
link: function(scope, element, attrs) {
scope.dialogStyle = {};
if (attrs.width)
scope.dialogStyle.width = attrs.width;
if (attrs.height)
scope.dialogStyle.height = attrs.height;
if (attrs.overflow)
scope.dialogStyle.overflow = attrs.overflow;
scope.hideModal = function() {
scope.show = false;
};
},
template: "<div class='ng-modal' ng-show='show'><div class='ng-modal-overlay'></div><div class='ng-modal-dialog' ng-style='dialogStyle'><div class='ng-modal-close' ng-click='hideModal()'><i class='fa fa-times-circle'></i></div><div class='ng-modal-dialog-content' ng-transclude></div></div></div>"// See below
};
});
我如果我点击模态取消按钮弹出我使用$ setpristine重置窗体,但如果有任何验证错误,当我点击关闭按钮(x)它调用hideModal()函数,所以模态获取关闭,但如果我重新打开模态弹出验证错误仍然存在模态popup.How我可以重置form.Here我的工作Plnkr https://plnkr.co/edit/embFJFmautH3uRbHOWU7?p=preview
使用$ scope.formName $ setPristine()。 请参阅本https://stackoverflow.com/a/21571392/6804648 –
@ Ushma乔希感谢您的答复,但我已经做了复位点击取消按钮就像你说的时候,但是当我点击关闭按钮(X)的模式弹出我我无法通过表单名称。是否有解决方案? – user7098427
你能分享你的html代码吗? –