Skip to content

Instantly share code, notes, and snippets.

@zekenie
Created May 19, 2016 23:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zekenie/69910d07899170e6d9f158ccd4166466 to your computer and use it in GitHub Desktop.
Save zekenie/69910d07899170e6d9f158ccd4166466 to your computer and use it in GitHub Desktop.
<!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