Skip to content

Instantly share code, notes, and snippets.

@limichange
Created March 1, 2014 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save limichange/9285418 to your computer and use it in GitHub Desktop.
Save limichange/9285418 to your computer and use it in GitHub Desktop.
repeat
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<div ng-controller="HelloController">
<div ng-repeat="item in items">
<div>
<span ng-bind="item.title"></span>
<span>-</span>
<span ng-bind="item.quantity"></span>
<span>-</span>
<span ng-bind="item.price | currency"></span>
<span>-</span>
<span><button ng-click="remove($index)">remove</button></span>
</div>
</div>
</div>
<div>
<form action="#" ng-submit="requestFunding()" ng-controller="StratUpController">
Staring: <input ng-change="computeNeeded()"
ng-model="startingEstimate">
Recommendation: <span ng-bind="needed"></span>
<button>Fund my startup!</button>
<button ng-click="reset()">Reset</button>
</form>
</div>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
function HelloController($scope, $location){
$scope.items = [
{title: 'title 1', quantity: 8, price: 3.94},
{title: 'title 2', quantity: 7, price: 23.94},
{title: 'title 3', quantity: 4, price: 33.94},
];
$scope.remove = function(index){
$scope.items.splice(index, 1);
}
}
function StratUpController($scope){
$scope.computeNeeded = function(){
$scope.needed = $scope.startingEstimate * 10;
};
$scope.requestFunding = function(){
window.alert("Sorry, please get more customers first.");
}
$scope.reset = function(){
$scope.startingEstimate = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment