Skip to content

Commit

Permalink
Organização da estrutura do código
Browse files Browse the repository at this point in the history
  • Loading branch information
juniorconte committed May 11, 2017
1 parent b9eaad3 commit 3e7b40d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ angular.module('todoApp')

var ref = firebase.database().ref().child('todos');

$scope.hide = $cookies.get('hide') === 'true' || false;
$scope.todos = $firebaseArray(ref);
$scope.hide = $cookies.get('hide') === 'true' || false;

$scope.addTodo = function(title) {
$scope.todos.$add({
Expand All @@ -22,12 +22,6 @@ angular.module('todoApp')
});
};

$scope.progress = function() {
return $scope.todos.filter(function(todo) {
return todo.done;
}).length / $scope.todos.length * 100;
};

$scope.clean = function() {
$scope.todos.forEach(function(todo) {
if (todo.done) {
Expand All @@ -36,8 +30,14 @@ angular.module('todoApp')
});
};

$scope.saveHide = function() {
$cookies.put('hide', $scope.hide);
$scope.progress = function() {
return $scope.todos.filter(function(todo) {
return todo.done;
}).length / $scope.todos.length * 100;
};

$scope.saveHide = function(hide) {
$cookies.put('hide', hide);
};

});
2 changes: 1 addition & 1 deletion app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>Firetasks</h1>
<div class="col-xs-6">
<button type="button"
class="btn btn-warning btn-block"
ng-click="hide = !hide; saveHide()">
ng-click="hide = !hide; saveHide(hide)">
{{hide && 'Exibir' || 'Esconder'}} concluídas
</button>
</div>
Expand Down

0 comments on commit 3e7b40d

Please sign in to comment.