Created
May 4, 2015 21:50
-
-
Save superchris/9e46e05134170dc68bad to your computer and use it in GitHub Desktop.
JS Bin Service example // source http://jsbin.com/xihuti
This file contains hidden or 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 ng-app="fruit"> | |
| <head> | |
| <meta name="description" content="Service example" /> | |
| <script src="http://code.jquery.com/jquery.min.js"></script> | |
| <link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
| <link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" /> | |
| <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script> | |
| <script src="http://code.angularjs.org/1.2.12/angular-route.js"></script> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <div ng-controller="FruitCtrl">{{fruit.cores}}</div> | |
| <div ng-controller="Fruit2Ctrl">{{fruit.cores}}<input ng-click="increment()" type="button" value="More cores!"/></div> | |
| <script id="jsbin-javascript"> | |
| fruit = angular.module("fruit", []); | |
| fruit.service("Fruit", function() { | |
| this.name = "Apples"; | |
| this.cores = 1; | |
| this.incrementCores = function() { | |
| this.cores = this.cores + 1; | |
| } | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); | |
| fruit.controller("Fruit2Ctrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| $scope.increment = function() { | |
| this.fruit.incrementCores(); | |
| } | |
| }); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">fruit = angular.module("fruit", []); | |
| fruit.service("Fruit", function() { | |
| this.name = "Apples"; | |
| this.cores = 1; | |
| this.incrementCores = function() { | |
| this.cores = this.cores + 1; | |
| } | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); | |
| fruit.controller("Fruit2Ctrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| $scope.increment = function() { | |
| this.fruit.incrementCores(); | |
| } | |
| }); | |
| </script></body> | |
| </html> |
This file contains hidden or 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
| fruit = angular.module("fruit", []); | |
| fruit.service("Fruit", function() { | |
| this.name = "Apples"; | |
| this.cores = 1; | |
| this.incrementCores = function() { | |
| this.cores = this.cores + 1; | |
| } | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); | |
| fruit.controller("Fruit2Ctrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| $scope.increment = function() { | |
| this.fruit.incrementCores(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment