src/app/quotebuilder/quote-builder.service.ts
constructor()
|
|
addQuote |
addQuote(name: string, amount: number)
|
Adds the quote object from the quote dialog to the quoteList
Parameters :
Returns:
void
|
getNumQuoteItems |
getNumQuoteItems()
|
Gets the number of quote items added
Returns:
void
|
isQuoteStarted |
isQuoteStarted()
|
Evaluates to true if the quoteList has been added to at least once
Returns:
void
|
getQuoteList |
getQuoteList()
|
Returns the array of quote elements
Returns:
void
|
Private quoteList |
quoteList: |
An array of all quote elements added from the imagerec component |
Private quoteStarted |
quoteStarted: |
Default value: false
|
Evaluates to true if the quoteList has been added to at least once |
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class QuoteBuilderService {
/**
* An array of all quote elements added from the imagerec component
*/
private quoteList: any[] = [];
/**
* Evaluates to true if the quoteList has been added to at least once
*/
private quoteStarted = false;
/**
* @ignore
*/
constructor() { }
/**
* Adds the quote object from the quote dialog to the quoteList
* @param name The name of the item that is to be part of the quote
* @param amount The amount of the item that is part of the quote
*/
addQuote(name: string, amount: number) {
const quote = {
'name': name,
'amount': amount
};
this.quoteList.push(quote);
this.quoteStarted = true;
}
/**
* Gets the number of quote items added
*/
getNumQuoteItems() {
return this.quoteList.length;
}
/**
* Evaluates to true if the quoteList has been added to at least once
*/
isQuoteStarted() {
return this.quoteStarted;
}
/**
* Returns the array of quote elements
*/
getQuoteList() {
return this.quoteList;
}
}