Skip to content

Instantly share code, notes, and snippets.

@danielpsf
Created March 19, 2014 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpsf/9641009 to your computer and use it in GitHub Desktop.
Save danielpsf/9641009 to your computer and use it in GitHub Desktop.
A Pen by Daniel Pedro dos Santos Fernandes.
<html>
<head>
<title>"Test"</title>
</head>
<body data-ng-app="myApp">
<div data-ng-app="myCtrl1">
<input type="number" data-ng-model="age"/>
</div>
<div data-ng-app="myCtrl2">{{age}}</div>
</body>
</html>
angular.module('myApp', [])
.factory('myService', function() {
var service = {};
service.age = 0;
return service;
})
.controller('myCtrl1', function($scope, myService) {
myService.age = $scope.age;
})
.controller('myCtrl2', function($scope, myService) {
$scope.age = myService.age;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment