Within the controller that triggers the dialog, I have:
$scope.openDialog = function () {
var options = dialogOptionsFactory.build('/my/route/file.html', 'ChildController');
var d = $dialog.dialog(options);
d.open().then(function (result) {
if (result) {
// THIS ACTION IS DELAYED UNTIL DIALOG IS REOPENED!
$scope.myresult = result;
}
});
};
In the dialog controller, the code looks something like this:
listModule.controller('ChildController', ['$scope', '$rootScope', 'dialog', function ($scope, $rootScope, dialog) {
$scope.uploadComplete = function (ifrm) {
var response = angular.element(ifrm).contents().find("body").text();
var responseObj = eval("(" + response + ")"); //Parentheses are necessary to convert JSON to JS object.
$scope.close(responseObj.Data);
};
$scope.close = function (result) {
dialog.close(result);
};
}]);
Why does the "then" promise not trigger until after reopening the dialog?
Update: I included additional details that I believe could be relevant. The data retrieval is from a concealed iframe's body. The promise functions properly when $scope.close()
is directly called. This suggests there may be an issue with the iframe or passing back an object to dialog.close().