diff --git a/angular-ui-router-uib-modal.js b/angular-ui-router-uib-modal.js index a790e71..ea073b4 100644 --- a/angular-ui-router-uib-modal.js +++ b/angular-ui-router-uib-modal.js @@ -45,14 +45,28 @@ angular.module("ui.router.modal", ["ui.router"]) } } - var thisModal = openModal = $uibModal.open(options); + var openModalFunc = function () { + var thisModal = openModal = $uibModal.open(options); - openModal.result['finally'](function() { - if (thisModal === openModal) { - // Dialog was closed via $uibModalInstance.close/dismiss, go to our parent state - $state.go($state.get("^", stateName).name); - } - }); + openModal.result['finally'](function() { + if (thisModal === openModal) { + // Dialog was closed via $uibModalInstance.close/dismiss, go to our parent state + $state.go($state.get("^", stateName).name); + } + }); + + } + + + if (options.templateProvider) { + options.templateProvider().then(function (template) { + options.template = template; + openModalFunc(); + }) + } + else { + openModalFunc(); + } }; // Make sure that onEnter receives state.resolve configuration diff --git a/src/angular-ui-router-uib-modal.js b/src/angular-ui-router-uib-modal.js index 057311f..70a9998 100644 --- a/src/angular-ui-router-uib-modal.js +++ b/src/angular-ui-router-uib-modal.js @@ -33,14 +33,28 @@ angular.module("ui.router.modal", ["ui.router"]) } } - var thisModal = openModal = $uibModal.open(options); + var openModalFunc = function () { + var thisModal = openModal = $uibModal.open(options); - openModal.result['finally'](function() { - if (thisModal === openModal) { - // Dialog was closed via $uibModalInstance.close/dismiss, go to our parent state - $state.go($state.get("^", stateName).name); - } - }); + openModal.result['finally'](function() { + if (thisModal === openModal) { + // Dialog was closed via $uibModalInstance.close/dismiss, go to our parent state + $state.go($state.get("^", stateName).name); + } + }); + + } + + + if (options.templateProvider) { + options.templateProvider().then(function (template) { + options.template = template; + openModalFunc(); + }) + } + else { + openModalFunc(); + } }; // Make sure that onEnter receives state.resolve configuration