-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
110 lines (95 loc) · 3.5 KB
/
index.js
File metadata and controls
110 lines (95 loc) · 3.5 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var myApp = angular.module('myApp', ['ui.router', 'ui.bootstrap']);
myApp.controller('todoCtrl',
['myService', '$scope', '$http', '$uibModal','$log',
function(myService, $scope, $http, $uibModal, $log) {
var tdc = this;
// tdc.todoInput = "test"; tdc.todoText = "test";
tdc.orderValue = null;
$http.get("tasklist.json").then(function (response) {
tdc.tasks = response.data;
tdc.addTask = function() {
// console.log(tdc.todoInput + " - " + tdc.todoText + " - tdc in addTask");
tdc.tasks.push({todoText: tdc.todoInput, todoInfo: tdc.todoText, done:false});
tdc.todoInput = "";
tdc.todoText = "";
console.log(tdc.tasks);
myService.tasksData = tdc.tasks;
};
tdc.remove = function() {
var oldList = tdc.tasks;
tdc.tasks = [];
angular.forEach(oldList, function(x) {
if (!x.done){
tdc.tasks.push(x);
// console.log(x);
}
});
myService.tasksData = tdc.tasks;
};
// for modal
$scope.open = function(){
var modalInstance = $uibModal.open({
animation: false,
templateUrl: 'myModalContent.html',
controller: 'ModalnstanceCtrl',
resolve: {
items: function () {
// console.log(tdc.todoInput, tdc.todoText)
var resolveData = {todoInput: tdc.todoInput, todoText: tdc.todoText};
return resolveData;
}
}
});
modalInstance.result.then(
function (resolveData) {
tdc.todoInput = resolveData.todoInput;
// console.log(resolveData.todoInput + " - resolveData.todoInput ");
// console.log(resolveData.todoText + " - resolveData.todoText ");
tdc.todoText = resolveData.todoText;
$log.info(tdc.todoInput + " from Press Ok");
tdc.addTask();
$log.info('PRESS OKEY');
},
function () {
$log.info('PRESS CANCEL');
});
}
});
}]);
myApp.controller('theTaskCtrl', ['$stateParams', 'myService',
function($stateParams, myService) {
var thtsk = this;
thtsk.tasksData = myService.tasksData[$stateParams.id];
}]);
myApp.config(function($stateProvider, $urlRouterProvider){
//if url is undefined go to home
$urlRouterProvider.otherwise("/")
// if user choose one task use it
$stateProvider.state('thetask-qs', {
url: "/thetask?id",
templateUrl: "thetask.html",
// backdropClass : 'modal-backdrop h-full',
controller: "theTaskCtrl",
controllerAs: "thtsk"
})
.state("/", {
url: "/",
templateUrl: "list.html"
})
});
myApp.service('myService', function(){
this.tasksData = {};
});
myApp.controller('ModalnstanceCtrl', ['$scope', '$uibModalInstance',
'items', function ($scope, $uibModalInstance, items) {
$scope.items = items;
// console.log($scope.items+ " todoinput from InstanseCtrl")
$scope.ok = function () {
var resolveData = {todoInput: $scope.todoInput, todoText: $scope.todoInfo};
// console.log(resolveData.todoText + " scope OK after init")
$uibModalInstance.close(resolveData);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
}]);