Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First approach angular controller
//Todo app controller written in groovy, from https://angularjs.org/
def todoAngular = { $scope ->
$scope.todos = [
[text:'learn angular', done: true],
[text:'build an angular app', done: false]
]
$scope.addTodo = {
$scope.todos << [text:$scope.todoText, done:false]
$scope.todoText = ''
}
$scope.remaining = {
$scope.todos.inject(0) { acc, todo ->
todo.done ? acc + 1 : acc
}
}
$scope.archive = {
$scope.todos = $scope.todos.findAll { !it.done }
}
}
/*And using it is js:
angular.module('todoApp', [])
.controller('TodoController', ['$scope', todoAngular]);
*/
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.