Created
March 31, 2015 13:44
-
-
Save brunoksato/5b580fe0fd8782ccd900 to your computer and use it in GitHub Desktop.
This file contains 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
angular.module('teste', []) | |
.controller('OneCtrl', OneCtrl) | |
.controller('SecondCtrl', SecondCtrl) | |
.service('ServiceGlobal', ServiceGlobal); | |
function OneCtrl($scope, ServiceGlobal){ | |
$scope.data = {id: 1, nome: 'ola mundo'}; | |
ServiceGlobal.addData($scope.data, true); | |
} | |
function SecondCtrl($scope, ServiceGlobal){ | |
$scope.data = ServiceGlobal.getData(); | |
} | |
function ServiceGlobal(){ | |
var data = []; | |
var _clearData = function(){ | |
data = []; | |
} | |
var _addData = function(value, clear){ | |
if(clear) | |
_clearData(); | |
data.push(value); | |
} | |
var _getData = function(){ | |
return data; | |
} | |
return { | |
addData: _addData, | |
getData: _getData | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment