angular Controller event is not firing on custom alert

夙愿已清 提交于 2019-12-24 12:57:29

问题


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"/>

回答1:


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



来源:https://stackoverflow.com/questions/26669939/angular-controller-event-is-not-firing-on-custom-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!