-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (57 loc) · 1.44 KB
/
app.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
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
( function(){
'use strict';
angular.module('assignment2',[])
.controller('ToBuyController',ToBuyController)
.controller('AlreadyBoughtController',AlreadyBoughtController)
.service('ShoppingListCheckOffService',ShoppingListCheckOffService);
ToBuyController.$inject=['ShoppingListCheckOffService'];
var items1=[];
function ToBuyController(ShoppingListCheckOffService){
var tobuy=this;
tobuy.items=ShoppingListCheckOffService.getItems();
tobuy.removeItem=function(index){
ShoppingListCheckOffService.removeItem(index);
}
}
AlreadyBoughtController.$inject=['ShoppingListCheckOffService'];
function AlreadyBoughtController(ShoppingListCheckOffService){
var already=this;
already.items=items1;
}
function ShoppingListCheckOffService(){
var service=this;
var items=[
{
name:"Cookies",
quantity:"10 packs"
},
{
name:"Coke",
quantity:"5 bottels"
},
{
name:"Burger",
quantity:"10 piece "
},
{
name:"Uncle Chips",
quantity:"5 packs"
},
{
name:"Five star",
quantity:"3 packs"
}
];
service.getItems=function(){
return items;
};
service.removeItem=function(index){
var item={
name:items[index].name,
quantity:items[index].quantity
};
items1.push(item);
items.splice(index,1);
};
}
})();