我有形式模式彈出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代碼嗎? –