mirror of
https://github.com/Raghu-Ch/Quickstart4.git
synced 2026-02-10 12:43:02 -05:00
Initial commit
This commit is contained in:
28
src/app/customer-list/customer-list.component.ts
Normal file
28
src/app/customer-list/customer-list.component.ts
Normal 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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user