Created
December 15, 2017 12:52
-
-
Save victorhqc/ec2aea2f6fe9622b9556cb6b27e43ab4 to your computer and use it in GitHub Desktop.
Angular 1.X Redux-Controller
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
var myApp = angular.module('myApp',[]); | |
myApp.controller('MyCtrl', function($scope, TodoService) { | |
function addTodo($scope, TodoService) { | |
return function curriedAddTodo(title, description) { | |
$scope.title = ''; | |
$scope.description = ''; | |
$scope.todos = TodoService.todosReducer( | |
$scope.todos, | |
TodoService.addTodo(title, description) | |
); | |
}; | |
} | |
function removeTodo($scope, TodoService) { | |
return function curriedRemoveTodo(id) { | |
$scope.todos = TodoService.todosReducer( | |
$scope.todos, | |
TodoService.removeTodo(id) | |
); | |
}; | |
} | |
$scope.todos = TodoService.todosReducer([], {}); | |
$scope.addTodo = addTodo($scope, TodoService); | |
$scope.removeTodo = removeTodo($scope, TodoService) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment