Initial commit

This commit is contained in:
2017-06-16 21:07:23 -04:00
commit 1f53b639f5
43 changed files with 905 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
h1 {
color: navy;
}
.selected {
color: purple;
font-weight: bold;
}

View File

@@ -0,0 +1,9 @@
<h1>Customers</h1>
<p><i>select a customer</i></p>
<ul>
<li *ngFor="let cust of customers" [ngClass]="{selected: customer===cust}" (click)="customer=cust">{{cust.name}}</li>
</ul>
<!--*ngIf Structural Directive show div if no customer is selected-->
<div *ngIf="customer">
<app-customer-detail [customer]="customer" (shift)="shift($event)"></app-customer-detail>
</div>

View File

@@ -0,0 +1,28 @@
import { Component, OnInit } from '@angular/core';
import { Customer } from 'app/customer.model';
import { DataService } from 'app/data.service';
import { LoggerService } from 'app/logger.service';
@Component({
selector: 'app-customer-list',
templateUrl: './customer-list.component.html',
styleUrls: ['./customer-list.component.css']
})
export class CustomerListComponent implements OnInit {
customers: Customer[];
customer: Customer;
constructor(private dataService: DataService, private loggerService: LoggerService) { }
ngOnInit() {
this.loggerService.log('Getting customers');
this.customers = this.dataService.getCustomers();
}
shift(increment: number) {
let ix = this.customers.findIndex(c => c === this.customer) + increment;
ix = Math.min(this.customers.length - 1, Math.max(0, ix));
this.customer = this.customers[ix];
}
}