One issue that I am facing is integrating the object returned by a dialog created with Angular Material Design Dialog ($mdDialog) into a collection present in the main controller of my application. Is there a feasible solution for achieving this?
angular.module("module").controller("mainController", function ($scope, $mdDialog) {
$scope.Users = [];
function OpenEditWindow(userToEdit) {
$mdDialog.show({
templateUrl: 'Views/user.html',
controller: 'UserDialogController',
clickOutsideToClose: true,
locals: { // Sending values to the dialog controller
User: userToEdit
}
}).then(function (data) {
// Trying to add the edited object to the main controller's collection for display
$scope.Users.push(data); // ******** ISSUE HERE
});
}
});
angular.module('module')
.controller('UserDialogController', function ($scope, $mdDialog, User) {
$scope.User = User;
$scope.Save = function () {
$mdDialog.hide($scope.User);
}
});