Trigger a digest cycle when opening modals with dynamic content

This commit is contained in:
Matt-Yorkley
2021-08-03 13:19:36 +01:00
parent 5fb782aeba
commit 5d4d3d4fcf
10 changed files with 31 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
angular.module("admin.utils").directive 'helpModal', ($compile, $templateCache, $window, DialogDefaults) ->
angular.module("admin.utils").directive 'helpModal', ($rootScope, $compile, $templateCache, $window, DialogDefaults) ->
restrict: 'C'
scope:
template: '@'
@@ -10,8 +10,11 @@ angular.module("admin.utils").directive 'helpModal', ($compile, $templateCache,
template.dialog(DialogDefaults)
# Link opening of dialog to click event on element
element.bind 'click', (e) -> template.dialog('open')
element.bind 'click', (e) ->
template.dialog('open')
$rootScope.$evalAsync()
scope.close = ->
template.dialog('close')
$rootScope.$evalAsync()
return

View File

@@ -10,12 +10,15 @@ angular.module("admin.utils").factory 'ConfirmDialog', ($rootScope, $q, $compile
template = $compile($templateCache.get('admin/confirm_dialog.html'))(scope)
template.dialog(DialogDefaults)
template.dialog('open')
$rootScope.$evalAsync()
scope.confirm = ->
deferred.resolve()
template.dialog('close')
$rootScope.$evalAsync()
null
scope.close = ->
deferred.reject()
template.dialog('close')
$rootScope.$evalAsync()
null
deferred.promise

View File

@@ -15,8 +15,10 @@ angular.module("admin.utils").factory 'InfoDialog', ($rootScope, $q, $compile, $
template = $compile($templateCache.get(templateUrl))(scope)
template.dialog(DialogDefaults)
template.dialog('open')
$rootScope.$evalAsync()
scope.close = ->
deferred.resolve()
template.dialog('close')
$rootScope.$evalAsync()
null
deferred.promise