角度控制器事件不会触发自定义警报 [英] angular Controller event is not firing on custom alert

查看:32
本文介绍了角度控制器事件不会触发自定义警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是点击事件没有从 alert.html 触发.

在 index.html 中,我已经包含了分配给 outputController 的 output.html,在 output.html 中,我已经包含了 alert.html,默认情况下,alert.html 将被隐藏.

当我点击 output.html 中的按钮时,它会触发 openWindow() 方法,在它内部会调用 javascript alert 方法.(因为我们已经覆盖了 window.alert 方法来更改正常基本警报的视图.)我可以在警报对话框中获取视图,甚至可以访问 alert.html 中的 $scope 成员变量,但是我的问题是我不能触发点击事件.任何人都可以告诉我我的代码可能有什么问题.

OutputController.js

 App.controller('OutputController',[ '$scope',function($scope){$scope.testVal = "Ajith";$scope.checkClick = function () {console.log("点击");};$scope.openWindow = 函数(标题){alert(angular.element(document.querySelector("#HtmlA"))).html(), title);};}]);


index.html

 

<div class="outputTab" ng-include src="'views/output.html'"></div>

output.html

 <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="点击这里"/>

解决方案

根据上述建议,我已经删除了我的 custom alert,我使用了 angular-ui modal popup.它工作正常.

http://plnkr.co/edit/FEtJo3?p=preview

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆