AngularJS中带有自定义URL的Bootstrap Modal窗口

时间:2017-04-25 12:02:37

标签: angularjs angular-ui-router

我在同一个网址上的控制器内部使用ng-click打开了模式。 我需要为模态创建自定义URL。 我该怎么办?

dashboardAppControllers.controller('abcController', ['$scope', '$window', '$log', '$http', '$timeout', '$routeParams', '$uibModal', 'Notification', '$interval', 'userDetails', '$filter', function($scope, $window, $log, $http, $timeout, $routeParams, $uibModal, Notification, $interval, userDetails, $filter) {

   var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'remarksEditModal.html',
            controller: 'remarksEditModalControllers',
            size: "lg",
            windowClass: 'center-modal',
            resolve: {
                bookingInfo: function() {
                    return event;
                }
            }
   });

}]);

1 个答案:

答案 0 :(得分:0)

您可以创建该弹出窗口的不同状态,并使用onEnter属性将其打开。像这样的东西

.state("wizard", {
                url: '/wizard',
                params: {
                    somethingWhichTurnTrueOnclick: null
                }
                onEnter: function($state, $timeout, $uibModal) {
                    var openWizard = function() {
                        var modal = $uibModal.open({
                            animation: true,
                            templateUrl: 'remarksEditModal.html',
                            controller: 'remarksEditModalControllers',
                            size: "lg",
                            windowClass: 'center-modal',
                            resolve: {
                                bookingInfo: function() {
                                    return event;
                                }
                            }                            
                        });

                        modal.result.then(function(response) {
                            // console.log('Wizard closed', response );
                        });
                    };
                    openWizard(); // open wizard                    
});