Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div ng-app="CounterApp">
<div ng-controller="CounterCtrl">
<div ng-repeat="count in counts track by $index">
<input ng-model="counts[$index]">
<button ng-click="incScore($index)">Inc</button>
</div>
</div>
</div>
<script src="/angular/angular.js"></script>
<script src="/horizon/horizon.js"></script>
<script>
angular.module('CounterApp', [])
.controller('CounterCtrl', function($scope) {
$scope.counts = [0,0,0,0];
$scope.incScore = function(athleteNum) {
$scope.counts[athleteNum]++;
}
});
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div ng-app="HelpApp">
<div ng-controller="HelpCtrl">
<form>
<input placeholder="name" ng-model="newHelpRequest.name">
<input placeholder="problems" ng-model="newHelpRequest.message">
<button ng-click="getHelp(newHelpRequest)">Help!</button>
</form>
<ul>
<li ng-repeat="helpRequest in helpQueue">
{{helpRequest.name}} : {{helpRequest.message}}
</li>
</ul>
</div>
</div>
<script src="/angular/angular.js"></script>
<script src="/horizon/horizon.js"></script>
<script>
angular.module('HelpApp', [])
.controller('HelpCtrl', function($scope) {
$scope.reset = function() {
$scope.newHelpRequest = {};
}
$scope.getHelp = function(helpRequest) {
$scope.helpQueue.push(helpRequest);
$scope.reset();
};
$scope.newHelpRequest = {};
$scope.helpQueue = [
{
name: 'Zeke',
message: 'Pretty confused...'
}
];
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.