Created
December 25, 2013 07:49
-
-
Save sher/8121123 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script> | |
<meta name="description" content="Something" /> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body ng-app="app" ng-controller="AppCtrl"> | |
<div ng-controller="MainCtrl"> | |
<input type="text" ng-model='animal.name' /> {{ animal.name }} | |
<br /> | |
<input type="text" ng-model='cow.name' /> {{ cow.name }} | |
</div> | |
</body> | |
</html> |
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
app = angular.module('app', []); | |
app.controller('AppCtrl', function($rootScope){ | |
}); | |
app.controller('MainCtrl', function($scope, Animal, Cow){ | |
$scope.animal = new Animal(); | |
$scope.cow = new Cow(); | |
}); | |
app.provider('Animal', function(){ | |
function Animal() { | |
this.name = "Animal"; | |
} | |
Animal.prototype.constructor = Animal; | |
this.$get = function(){ | |
return Animal; | |
}; | |
}); | |
app.provider('Cow', function(AnimalProvider){ | |
function Cow() { | |
this.name = "Cow"; | |
} | |
Animal = AnimalProvider.$get(); | |
Cow.prototype = new Animal(); | |
Cow.prototype.constructor = Cow; | |
this.$get = function(){ | |
return Cow; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment