Last active
November 4, 2015 19:38
-
-
Save leonardocouy/a35d24b13435cc5669db to your computer and use it in GitHub Desktop.
pass variable between controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('AppExemplo', []) | |
app.service('InfoUsuario', function () { | |
var dados = { | |
nome: 'Leonardo Flores', | |
idade: 20, | |
} | |
return { | |
getDados: function () { | |
return dados; | |
}, | |
setDados: function(dadosUsuario) { | |
dados = dadosUsuario | |
}, | |
}; | |
}); | |
app.controller('ExemploController', function($scope, InfoUsuario) { | |
$scope.usuario = InfoUsuario.setDados({'nome': 'Joao', 'idade': 20}) | |
$scope.usuario = InfoUsuario.getDados() | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment