aboutsummaryrefslogtreecommitdiff
path: root/public/js/controllers
diff options
context:
space:
mode:
authorkumar dam <kumar.damani@mail.utoronto.ca>2017-04-30 01:38:53 +0000
committerkumar dam <kumar.damani@mail.utoronto.ca>2017-04-30 01:38:53 +0000
commitfb06a6490e1abcb56d2ca11a7e1ad812dceb943f (patch)
tree9eed1c89a5c4b7e568e52a1473e24d0d520a672d /public/js/controllers
parentd52437a4f88af931f130c7bb259949a84db65276 (diff)
fixed all indents
Diffstat (limited to 'public/js/controllers')
-rw-r--r--public/js/controllers/todoController.js81
1 files changed, 38 insertions, 43 deletions
diff --git a/public/js/controllers/todoController.js b/public/js/controllers/todoController.js
index eb73feb..08e5a3f 100644
--- a/public/js/controllers/todoController.js
+++ b/public/js/controllers/todoController.js
@@ -1,44 +1,39 @@
angular.module('todoController', [])
-
- // inject service factory into our controller
- .controller('mainController', ['$scope','$http','Todos', function($scope, $http, Todos) {
- $scope.formData = {};
- $scope.loading = true;
-
- // on first visit 'refresh' the todo list
- Todos.get()
- .success(function(data) {
- $scope.todos = data;
- $scope.loading = false;
- });
-
- // when submitting the add form, send formdata to api
- $scope.createTodo = function() {
-
- // validate the formData to make sure that something is there
- if ($scope.formData.text != undefined) {
- $scope.loading = true;
-
- Todos.create($scope.formData)
-
- // if successful creation, 'refresh' todo list
- .success(function(data) {
- $scope.loading = false;
- $scope.formData = ""; // clear the form
- $scope.todos = data; // assign our new list of todo
- });
- }
- };
-
- // delete a todo when pressed checkbox
- $scope.deleteTodo = function(id) {
- $scope.loading = true;
-
- Todos.delete(id)
- // if successful, 'refresh' the list with latest data
- .success(function(data) {
- $scope.loading = false;
- $scope.todos = data;
- });
- };
- }]); \ No newline at end of file
+ .controller('mainController', ['$scope', '$http', 'Todos', function($scope, $http, Todos) {
+ $scope.formData = {};
+ $scope.loading = true;
+
+ // on first visit 'refresh' the todo list
+ Todos.get()
+ .success(function(data) {
+ $scope.todos = data;
+ $scope.loading = false;
+ });
+
+ // when submitting the add form, send formdata to api
+ $scope.createTodo = function() {
+
+ // validate the formData to make sure that something is there
+ if ($scope.formData.text != undefined) {
+ $scope.loading = true;
+
+ Todos.create($scope.formData)
+ .success(function(data) { // refresh
+ $scope.loading = false;
+ $scope.formData = ""; // clear the form
+ $scope.todos = data; // assign our new list of todo
+ });
+ }
+ };
+
+ // delete a todo when pressed checkbox
+ $scope.deleteTodo = function(id) {
+ $scope.loading = true;
+
+ Todos.delete(id)
+ .success(function(data) { // refresh
+ $scope.loading = false;
+ $scope.todos = data;
+ });
+ };
+ }]);