Created
July 3, 2013 11:05
-
-
Save agektmr/5917056 to your computer and use it in GitHub Desktop.
Angular controller inheritance example
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 ng-app> | |
<head> | |
<title>Angular Example</title> | |
<meta charset="utf-8" /> | |
<link rel="stylesheet" href="styles/style.css"> | |
<script src="scripts/angular.min.js"></script> | |
<script> | |
var ListCtrl = function($scope) { | |
$scope.list = [ | |
{ | |
name: 'agektmr', | |
count: 0 | |
}, | |
{ | |
name: 'vvakame', | |
count: 0 | |
}, | |
{ | |
name: 'teyosh', | |
count: 0 | |
}, | |
{ | |
name: 'can_i_do_web', | |
count: 0 | |
} | |
]; | |
}; | |
var ItemCtrl = function($scope) { | |
$scope.increase = function() { | |
$scope.item.count++; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<section ng-controller="ListCtrl"> | |
<ul> | |
<li ng-repeat="item in list" ng-controller="ItemCtrl"> | |
<p>{{item.name}}: {{item.count}} <button ng-click="increase()">+</button></p> | |
</li> | |
</ul> | |
</section> | |
<footer> | |
</footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment