2
I have the following modal in my controller:
angular
.module('app', ['ui.bootstrap'])
.controller('AlunosController', function ($uibModal, $scope, MyPaginator) {
$scope.alunos = new MyPaginator('/alunos');
$scope.open = function (aluno) {
$scope.alunoOriginal = aluno;
$uibModal.open({
controller: 'ModalAlunoFormController',
resolve: {
aluno: function () {
return angular.copy(aluno);
}
}
})
};
})
.controller('ModalFormAlunoController', function ($uibModalInstance, aluno) {
$scope.aluno = aluno;
});
I can perfectly import the aluno
to the controller
modal, the ModalFormAlunoController
, using the option resolve
.
But I would like to pass all the objects present on $scope
of AlunosController
to the ModalFormAlunoController
, without having to pass one by an option route resolve
.
How can I do that in Angular UI Bootstrap?
Yeah, but that’s just gonna pass
aluno
. I need all the other values of$scope
ofAlunosController
be passed toModalFormAlunoController
. I mean, I’ll have access to all the other variables.– Wallace Maxters
When I take the test
console.log($scope.alunos)
in the Modal controller returnsundefined
. The main $Scope is not automatically passed– Wallace Maxters
Hello Wallace, remove "student" from controller injection, I will update the answer.
– Newton Pasqualini Filho
vc is trying to inject a "student" service that does not exist, and that was setting $Cope.student to Undefined.
– Newton Pasqualini Filho
I guess you still don’t understand what I was needing. I need to copy the data from one scope to the other. I even answered the question how to do. I think it’s good I set an example so no one gets confused.
– Wallace Maxters
https://gist.github.com/zachlysobey/d8edfdb73382314b6dd5
– Newton Pasqualini Filho
I did not understand how the code shown answers the question.
– Wallace Maxters
Let’s go continue this discussion in chat.
– Wallace Maxters