Advertisement
ikkew

Angular Customerview

Apr 19th, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ---------------------------- customerview.components.ts ----------------------------------------
  2.  
  3. import { Component, OnInit, Input } from '@angular/core';
  4. import { Observable } from 'rxjs/Rx';
  5.  
  6. import { Customer } from '../../../models/customer.model';
  7. import { CustomerService } from '../../../services/customer.service';
  8.  
  9. @Component({
  10.     selector: 'app-customerview',
  11.     templateUrl: './customerview.component.html',
  12.     styleUrls: ['./customerview.component.scss', '../../../css/general.component.scss']
  13. })
  14.  
  15. export class CustomerviewComponent implements OnInit {
  16.     @Input() extendedCustomer: boolean;
  17.     @Input() detailedCustomer: boolean;
  18.     @Input() customerID: string;
  19.  
  20.     currentCustomer: Customer;
  21.  
  22.     constructor(private _customerService: CustomerService) { }
  23.  
  24.     ngOnInit() {
  25.         this.getCurrentCustomer();
  26.     }
  27.  
  28.     getCurrentCustomer() {
  29.         this._customerService.getAllCustomers().subscribe(
  30.             (toReturnArray: any[]) => {
  31.                 this.currentCustomer = toReturnArray.filter(x => x.id == this.customerID)[0];
  32.             }
  33.         );
  34.     }
  35. }
  36.  
  37. // ---------------------------- customerview.components.html ----------------------------------------
  38.  
  39. <!-- Simple-->
  40. <md-card>
  41.     <a [routerLink]="['/customer', customerID]">
  42.         <img src="../../assets/placeholders/carglass.gif" alt="..." class="img_logo_size">
  43.         <md-card-subtitle class="card_subtitle_center">{{currentCustomer?.name}}</md-card-subtitle>
  44.     </a>
  45.     <!-- Extended-->
  46.     <div *ngIf="extendedCustomer">
  47.         <md-card-title class="card_title_center | spikes_red">Address {{currentCustomer?.name}}</md-card-title>
  48.         <md-card-content class="address_container | card_content_center">
  49.             <p>{{location?.streeth}} {{location?.number}}</p>
  50.             <p>{{location?.postcode}} {{location?.city}}</p>
  51.             <p>{{location?.country}}</p>
  52.         </md-card-content>
  53.  
  54.         <!-- Detailed -->
  55.         <div *ngIf="detailedCustomer">
  56.             <md-card-title class="card_title_center | spikes_red">Contact</md-card-title>
  57.             <md-card-content class="center_md-list">
  58.                 <md-list>
  59.                     <md-list-item layout-align="row">
  60.                         <md-icon md-list-avatar>
  61.                             <img src="../../assets/placeholders/sign-in-icon.png" alt="..." class="img_list_size_big">
  62.                         </md-icon>
  63.                         <div class="info_container | more_room_left_contact">
  64.                             <h4>{{customer?.name}}</h4>
  65.                             <h4>{{customer?.title}}</h4>
  66.                             <p>{{customer?.contactNumber}}</p>
  67.                         </div>
  68.                         <span flex></span>
  69.                     </md-list-item>
  70.                 </md-list>
  71.             </md-card-content>
  72.  
  73.             <md-card-title class="card_title_center | spikes_red">Address *customer.name*</md-card-title>
  74.             <md-card-content class="address_container | card_content_center">
  75.                 <p>{{location?.streeth}} {{location?.number}}</p>
  76.                 <p>{{location?.postcode}} {{location?.city}}</p>
  77.                 <p>{{location?.country}}</p>
  78.             </md-card-content>
  79.         </div>
  80.         <br>
  81.     </div>
  82. </md-card>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement