Skip to content

Instantly share code, notes, and snippets.

@mreis1
Created January 13, 2015 22:30
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 mreis1/eb7e8fb8b9eaf39ac6b3 to your computer and use it in GitHub Desktop.
Save mreis1/eb7e8fb8b9eaf39ac6b3 to your computer and use it in GitHub Desktop.
This is a template for angular experiments // source http://jsbin.com/feciqatari
<!doctype html>
<html ng-app="myApp">
<head>
<meta name="description" content="This is a template for angular experiments" />
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
</head>
<script src="http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js"></script>
<body>
<div ng-controller="foo">
{{binValue.getByte();}}
<input type="text" ng-model="value">
<a href="#" ng-click="setBin()">update</a>
</div>
<div ng-controller="bar">
{{binValue.getByte();}}
<input type="text" ng-model="binValue.byte">
<a href="#" ng-click="setBin()">update</a>
</div>
<script id="jsbin-javascript">
angular.module('myApp',[])
.controller('foo', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
$scope.value = 'foo';
function setBin(){
binFactory.setByte($scope.value)
}
})
.controller('bar', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
function setBin(){
binFactory.setByte($scope.value)
}
})
.factory('binFactory',function(){
var byte = 'dog';
var service = {
byte: byte,
getByte: getByte,
setByte: setByte
}
return service;
function getByte(){
return this.byte;
}
function setByte(value){
this.byte = value;
}
})
</script>
<script id="jsbin-source-javascript" type="text/javascript">angular.module('myApp',[])
.controller('foo', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
$scope.value = 'foo';
function setBin(){
binFactory.setByte($scope.value)
}
})
.controller('bar', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
function setBin(){
binFactory.setByte($scope.value)
}
})
.factory('binFactory',function(){
var byte = 'dog';
var service = {
byte: byte,
getByte: getByte,
setByte: setByte
}
return service;
function getByte(){
return this.byte;
}
function setByte(value){
this.byte = value;
}
})</script></body>
</html>
angular.module('myApp',[])
.controller('foo', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
$scope.value = 'foo';
function setBin(){
binFactory.setByte($scope.value)
}
})
.controller('bar', function(binFactory,$scope){
$scope.binValue = binFactory;
$scope.setBin = setBin;
function setBin(){
binFactory.setByte($scope.value)
}
})
.factory('binFactory',function(){
var byte = 'dog';
var service = {
byte: byte,
getByte: getByte,
setByte: setByte
}
return service;
function getByte(){
return this.byte;
}
function setByte(value){
this.byte = value;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment