Created
May 4, 2015 21:50
-
-
Save superchris/3a9582da2f72b1ea4907 to your computer and use it in GitHub Desktop.
JS Bin Provider example // source http://jsbin.com/hizami
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="Provider 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}} - {{fruit.name}}</div> | |
| <script id="jsbin-javascript"> | |
| fruit = angular.module("fruit", []); | |
| fruit.provider("Fruit", function() { | |
| this.cores = 0; | |
| this.$get = function() { | |
| return { | |
| cores: this.cores, | |
| name: "Apples" | |
| } | |
| }; | |
| this.setCores = function(cores) { | |
| this.cores = cores; | |
| }; | |
| }); | |
| fruit.config(function(FruitProvider) { | |
| FruitProvider.setCores(3); | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript"> | |
| fruit = angular.module("fruit", []); | |
| fruit.provider("Fruit", function() { | |
| this.cores = 0; | |
| this.$get = function() { | |
| return { | |
| cores: this.cores, | |
| name: "Apples" | |
| } | |
| }; | |
| this.setCores = function(cores) { | |
| this.cores = cores; | |
| }; | |
| }); | |
| fruit.config(function(FruitProvider) { | |
| FruitProvider.setCores(3); | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); | |
| </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.provider("Fruit", function() { | |
| this.cores = 0; | |
| this.$get = function() { | |
| return { | |
| cores: this.cores, | |
| name: "Apples" | |
| } | |
| }; | |
| this.setCores = function(cores) { | |
| this.cores = cores; | |
| }; | |
| }); | |
| fruit.config(function(FruitProvider) { | |
| FruitProvider.setCores(3); | |
| }); | |
| fruit.controller("FruitCtrl", function($scope, Fruit) { | |
| $scope.fruit = Fruit; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment