Last active
August 29, 2015 14:05
-
-
Save murphysean/6dcec6b89014a888c36d to your computer and use it in GitHub Desktop.
Angular Binding to Factory Value
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
<!doctype html> | |
<html lang="en" ng-app="testing"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Angular Binding From Controller to Service(Factory)</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.19/angular.js"></script> | |
</head> | |
<body> | |
<section ng-controller="TestController"> | |
<p>{{rwObject.name}}</p> | |
</section> | |
<section ng-controller="TestController"> | |
<input type="text" ng-model="rwObject.name"> | |
</section> | |
<script> | |
angular.module("testing",[]) | |
.controller('TestController',['$scope','rwObject', function TestController($scope, rwObject){ | |
$scope.rwObject = rwObject; | |
}]) | |
.factory('rwObject', [function clientIdFactory(){ | |
var rwObject = new Object(); | |
rwObject.name = "Sean Murphy" | |
return rwObject; | |
}]); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment