1
//Tenho uma injeção de dependência aqui
PedidoController.$inject = ['$rootScope', '$state','ModalService', NotificationService','PedidoService', 'BoletoService'];
// Construtor do meu controller
function PedidoController($rootScope,$state,ModalService, NotificationService, PedidoService,BoletoService)
//To passando um objeto para outro controller
function listarBoletos(pedido) { vm.boletos = pedido.boletos; $rootScope.$broadcast('BoletosSelecionados',pedido.boletos); $state.go('boleto');}
//Injection controller receptor
BoletoController.$inject = ['$scope','BoletoService'];
// Construtor Controller receptor
function BoletoController( $scope,BoletoService)
//Recepção do Objeto
$scope.$on('BoletosSelecionados',function (event, OEvent) { vm.boletos=OEvent; console.log(OEvent);
There’s a little mistake there on the first line:
'NotificationService'
does not have the initial single quotes.– OnoSendai
Since the two controllers have an injection of Boletoservice why don’t you store the orders in a variable within the Boletoservice? Services Singleton (an instance for the entire application) can be used to share variables. I believe you’re better at performance issues by eliminating the need to keep monitoring events.
– Rafael B. Marcílio
@Onosendai I took a look at the code and it is with the quotation mark, vlw.
– arthur cláudio
@Sorack not in my case I’m using the inject controller because of legacy code.
– arthur cláudio
@arthurcláudio It means that your code is different in relation to what you posted in the question?
– OnoSendai
Thank you for answering, man I’m new in angular JS , how would I do that? This code is legacy there ever saw.
– arthur cláudio
@Felipepaetzold some idea of how to fix it?
– arthur cláudio
@arthurcláudio puts the complete code of the controllers so I can help better
– Rafael B. Marcílio
@Felipepaetzold was just trying to help
– Rafael B. Marcílio