-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
33 lines (26 loc) · 850 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import angular from 'angular'
// import reactDirective from './src/angular/reactDirective'
const app = angular.module('app', []);
app.controller('TodoCtrl', function($scope) {
$scope.todos = [
{text:'learn angular', done:false},
{text:'build an angular app', done:false}];
$scope.addTodo = function() {
$scope.todos.push({text:$scope.todoText, done:false});
$scope.todoText = '';
};
$scope.remaining = function() {
var count = 0;
angular.forEach($scope.todos, function(todo) {
count += todo.done ? 0 : 1;
});
return count;
};
$scope.markItemCompleted = function(todoText) {
var index = $scope.todos.findIndex((item,index)=> { return (item.text === todoText) })
console.log(index)
$scope.todos[index].done = !$scope.todos[index].done
$scope.$apply()
};
})
export default app;