Last active
August 29, 2015 14:24
-
-
Save DinisCruz/a4483071f5095947706d to your computer and use it in GitHub Desktop.
variation of code used in http://blog.diniscruz.com/2014/02/using-angularjs-in-eclipse-part-2-add.html
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
function TodoCtrl( $scope ) | |
{ | |
$scope.todos = | |
[ | |
{ text: 'learn angular', done:true }, | |
{ text: 'build an angular app', done:false }, | |
{ text: 'A NEW Angular TO DO', done:true } | |
]; | |
$scope.addTodo = function() | |
{ | |
$scope.todos.push( { text: $scope.todoText, done:false} ); | |
$scope.todoText = 'Default Text after a new Todo'; | |
} | |
$scope.remaining = function() | |
{ | |
var count = 0; | |
angular.forEach( $scope.todos, function( todo ) | |
{ | |
count += todo.done ? 0 : 1; | |
} | |
); | |
} | |
} | |
/* vim: set tabstop=2 shiftwidth=2 expandtab: */ |
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> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> | |
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.css" /> | |
<script src="todo.js"></script> | |
<link rel="stylesheet" href="todo.css"> | |
</head> | |
<body> | |
<h2> Todo </h2> | |
<div ng-controller="TodoCtrl"> | |
<span>{{remaining()}} of {{todos.length}} remaining</span> | |
[ <a href="" ng-click="archive()">archive</a> ] | |
<ul class="unstyled"> | |
<li ng-repeat="todo in todos"> | |
<input type="checkbox" ng-model="todo.done" /> | |
<span class="done-{{todo.done}}">{{todo.text}}</span> | |
</li> | |
</ul> | |
<form ng-submit="addTodo()"> | |
<input type="text" ng-model="todoText" size="30" placeholder="add new todo here" /> | |
<input class="btn-primary" type="submit" value="add" /> | |
<p> | |
New Todo text: <b>{{todoText}}</b> | |
</p> | |
</form> | |
</div> | |
</body> | |
</html> | |
<!-- vim: set tabstop=2 shiftwidth=2 expandtab: --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment