Skip to content

Instantly share code, notes, and snippets.

@krawaller
Last active May 10, 2016 11:25
Show Gist options
  • Save krawaller/b9b228b740ba3ef3763ff6b6db494850 to your computer and use it in GitHub Desktop.
Save krawaller/b9b228b740ba3ef3763ff6b6db494850 to your computer and use it in GitHub Desktop.
angular cheating
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 1</title>
<script src="../jquery.js"></script>
<script src="../angular.js"></script>
<style>
.selected {
text-decoration: line-through;
}
</style>
</head>
<body ng-app="app" ng-controller="Ctrl">
<div ng-repeat="issue in issues" class="test" ng-class="{selected:issue.selected}">
<input type="checkbox" ng-model="issue.selected">
{{issue.text}}
</div>
<input type="text" ng-model="newIssue" placeholder="new issue"/>
<button ng-click="addNewIssue()">Add issue</button>
<pre ng-bind="issues | json"/>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('Ctrl',function($scope){
$scope.issues = [
{text: 'do the dishes'},
{text: 'take out trash'},
{text: 'make the bed'}
];
$scope.addNewIssue = function(){
$scope.issues.push({text:$scope.newIssue});
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment