Created
March 14, 2014 02:36
-
-
Save superchris/9541188 to your computer and use it in GitHub Desktop.
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="Factory 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> | |
| </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