Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit 0d9d518

Browse files
committedAug 1, 2017
cart items added
1 parent 87ae8c8 commit 0d9d518

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed
 

‎src/app/cart.service.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { observable } from 'rxjs/symbol/observable';
12
import { Injectable } from '@angular/core';
23
import { MdSnackBar } from '@angular/material';
4+
import { Observable } from 'rxjs/Observable';
35

46
@Injectable()
57
export class CartService {
@@ -73,7 +75,11 @@ export class CartService {
7375
});
7476
items.push(imageUrl);
7577
}
78+
7679
public getNitems(): number {
7780
return this.itemArray.length;
7881
}
82+
public getItems(): any {
83+
return this.itemArray;
84+
}
7985
}

‎src/app/dashboard/dashboard.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<md-nav-list dense>
1515
<a md-list-item *ngFor="let item of itemArray">
1616
<md-icon md-list-avatar>today</md-icon>
17-
<h4 md-line><span class="text-wrap">item</span></h4>
17+
<h4 md-line><span class="text-wrap">{{item}}</span></h4>
1818
</a>
1919
<md-divider *ngIf="!last"></md-divider>
2020
</md-nav-list>

‎src/app/dashboard/dashboard.component.ts

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,76 @@ import { Component, OnInit } from '@angular/core';
44
import { Title } from '@angular/platform-browser';
55
import { TdLoadingService, TdDigitsPipe, CovalentNotificationsModule } from '@covalent/core';
66
import { MdSnackBar } from '@angular/material';
7-
87
import { CartService } from '../cart.service';
98

109
@Component({
1110
selector: 'qs-dashboard',
1211
templateUrl: './dashboard.component.html',
13-
styleUrls: ['./dashboard.component.scss']
14-
// providers: [CartService],
12+
styleUrls: ['./dashboard.component.scss'],
1513
})
14+
1615
export class DashboardComponent implements OnInit {
16+
itemArray: any[] = [];
1717
imageArray: any[] = [{
1818

1919
columnSize: '40',
2020
column: [{
21+
name: '',
2122
url: '../../assets/images/alex-lambley-205711-min.jpg',
2223
isclicked: false,
2324
}, {
25+
name: '',
2426
url: '../../assets/images/norman-toth-177290-min.jpg',
2527
isclicked: false,
2628
}, {
29+
name: '',
2730
url: '../../assets/images/kaci-baum-108756-min.jpg',
2831
isclicked: false,
2932
}, {
33+
name: '',
3034
url: '../../assets/images/ariel-lustre-232891-min.jpg',
3135
isclicked: false,
3236
}],
3337
}, {
3438
columnSize: '25',
3539
column: [{
40+
name: '',
3641
url: '../../assets/images/pete-bellis-189599-min.jpg',
3742
isclicked: false,
3843
}, {
44+
name: '',
3945
url: '../../assets/images/remy_loz-188297-min.jpg',
4046
isclicked: false,
4147
}, {
48+
name: '',
4249
url: '../../assets/images/brooke-cagle-195860-min.jpg',
4350
isclicked: false,
4451
}, {
52+
name: '',
4553
url: '../../assets/images/freestocks-org-195640-min.jpg',
4654
isclicked: false,
4755
}],
4856
}, {
4957
columnSize: '25',
5058
column: [{
59+
name: '',
5160
url: '../../assets/images/pete-bellis-189613-min.jpg',
5261
isclicked: false,
5362
}, {
63+
name: '',
5464
url: '../../assets/images/pete-bellis-191833-min.jpg',
5565
isclicked: false,
5666
},
5767
],
5868
}, {
5969
columnSize: '25',
6070
column: [{
71+
name: '',
6172
url: '../../assets/images/valerie-elash-275588-min.jpg',
6273
isclicked: false,
6374
},
6475
{
76+
name: '',
6577
url: '../../assets/images/jason-blackeye-221058-min.jpg',
6678
isclicked: false,
6779
}],
@@ -76,18 +88,24 @@ export class DashboardComponent implements OnInit {
7688

7789
ngOnInit(): void {
7890
this._titleService.setTitle('Covalent Quickstart');
91+
this.itemArray = this.cartService.getItems();
7992
}
8093

8194
clickedImage(imageUrl: any): void {
8295
this.router.navigate(['/image-view', { url: imageUrl }]);
83-
8496
}
97+
8598
clickedAddToCart(imageUrl: any): void {
8699
const img: string = imageUrl;
87100
this.cartService.clickedAddToCart(img);
88101
}
102+
89103
notifications(): number {
90104
const nItems: number = this.cartService.getNitems();
91105
return nItems;
92106
}
107+
108+
clickedCart(): void {
109+
this.itemArray = this.cartService.getItems();
110+
}
93111
}

‎src/app/models.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface Item {
2+
name: string;
3+
img: String;
4+
isClicked: boolean;
5+
amount: number;
6+
}
7+
export interface Image {
8+
name: string;
9+
img: string;
10+
isClicked: boolean;
11+
}

‎tslint.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
true,
66
"statements"
77
],
8+
"experimentalDecorators":false,
89
"array-type": [
910
true,
1011
"array"

0 commit comments

Comments
 (0)
This repository has been archived.