I'm new to AngularJS and I'm trying to make a simple CRUD. I'm trying to pass data from one screen to another using a service, but it does not work and I can not figure out why. Follow my code.
Follow my code
var app = angular.module("app", []);
app.factory('clienteService', function () {
var savedCliente = {};
function set(cliente) {
savedCliente = cliente;
}
function get() {
return savedCliente;
}
return {
set: set,
get: get
}
app.controller("clientesCtrl", function ($scope, $http, clienteService) {
$scope.SetDados = function (cliente) {
clienteService.set(cliente);
}
});
app.controller('AltararClienteCtrl', function ($scope, $http, clienteService) {
$scope.init = function () {
$scope.cliente = clienteService.get();
}
});