A Pen by Daniel Pedro dos Santos Fernandes on CodePen.
Created
March 19, 2014 12:52
-
-
Save danielpsf/9641009 to your computer and use it in GitHub Desktop.
A Pen by Daniel Pedro dos Santos Fernandes.
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
<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> |
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('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