角控制器事件在不触发自定义警报 [英] angular Controller event is not firing on custom alert
问题描述
我的问题是Click事件不会从alert.html射击。
在index.html的我已经包含output.html分配给outputController,在output.html我已经包括alert.html默认alert.html将被隐藏。
当我点击一个按钮,从output.html它会火的openWindow()方法,它里面会调用JavaScript的alert方法。 (如果我们已经覆盖了window.alert方法来改变基本正常警报的观点)。我可以能够得到警报对话视图,连我都能够访问alert.html的$范围,成员变量,但我的问题是我能不火单击事件。有人建议我,这可能是与我的code中的问题。
OutputController.js
App.controller('OutputController',['$范围',函数($范围){
$ scope.testVal =阿吉特;
$ scope.checkClick =功能(){
的console.log(点击);
};
$ scope.openWindow =功能(标题){
警报(angular.element(document.querySelector(#HTMLA)))HTML(),标题)。
};
}]);
的index.html
< DIV CLASS =Tab页ID =tabpage_4NG控制器=OutputController>
< DIV CLASS =outputTabNG-包括SRC ='意见/ output.html'>< / DIV>
< / DIV>
output.html
<输入类型=按钮NG点击=的openWindow('A')VALUE =OenAlert/>
< DIV ID =HTMLANG控制器=OutputControllerNG-的init =类型='A'
NG-包括='意见/ alert.html'NG隐藏=真>< / DIV>
alert.html
{{}名为testVal}
<输入类型=按钮NG点击=checkClick()VALUE =点击这里/>
按照上述建议,我已删除了我的自定义的警报
,我已经使用棱角分明的UI模式弹出
。这是工作的罚款。
http://plnkr.co/edit/FEtJo3?p=$p$ PVIEW
My Problem is Click event is not firing from alert.html.
In index.html I have included output.html assigned to outputController, in output.html I have included alert.html by default alert.html will be hidden.
When I click on a button from output.html it will fire openWindow() method, inside it will call javascript alert method. (Where as we have overwritten the window.alert method to change the view of normal basic alert.) I can able to get the view in alert dialogue and even I can able to access the $scope member variable in alert.html but my problem is I can not fire click event. anyone suggest me what could be the problem with my code.
OutputController.js
App.controller('OutputController',[ '$scope',function($scope){
$scope.testVal = "Ajith";
$scope.checkClick = function () {
console.log("Clicked");
};
$scope.openWindow = function (title) {
alert(angular.element(document.querySelector("#HtmlA"))).html(), title);
};
}]);
index.html
<div class="tabpage" id="tabpage_4" ng-controller="OutputController">
<div class="outputTab" ng-include src="'views/output.html'"></div>
</div>
output.html
<input type="button" ng-click="openWindow('A')" value="OenAlert"/>
<div id="HtmlA" ng-controller="OutputController" ng-init="Type = 'A'"
ng-include="'views/alert.html'" ng-hide="true"></div>
alert.html
{{testVal}}
<input type="button" ng-click="checkClick()" value="Click Here"/>
As per above suggestions I have removed my custom alert
, I have used angular-ui modal popup
. It was working fine.
http://plnkr.co/edit/FEtJo3?p=preview
这篇关于角控制器事件在不触发自定义警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!