Bootstrap modal popup open and close using angularjs not working

丶灬走出姿态 提交于 2019-12-17 21:23:43

问题


Hi i want to open and close the bootstrap model popup by using angularjs controller.js code.

my controller code

app.controller('RoleViewCtrlq', ['$scope', '$modalInstance', '$modal',
function ($scope, $modalInstance, $modal) {


    $scope.open = function () {
        debugger;
        var modalInstance = $modal.open({
            templateUrl: 'myModalContent.html',
        });


        $scope.ok = function () {
            $modalInstance.close();
        };

        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };


    }
}
]);

Here i have create the sample https://plnkr.co/edit/xRhCR7qidlr24M8nAOA6?p=preview

it is not working to open and close my pop up in controller.js code. can any one check the issue.??


回答1:


 <script type="text/ng-template" id="myModalContent.html">

Remove this script tag from HTML and try again. It is working




回答2:


In the Plunker you have provided, you have not set any myModalContent.html.

When using:

var modalInstance = $modal.open({
    templateUrl: 'myModalContent.html'
});

Angular will check for a myModalContent.html file to include in the modal. It means creating the modal from a template.

After reviewing your code, I think this is not exactly what you are trying to achieve:

Forked your Plunker



来源:https://stackoverflow.com/questions/43583136/bootstrap-modal-popup-open-and-close-using-angularjs-not-working

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