/** * @Component Name: CreditOptionsComponent * @Module: Home * @Module Functionality : To display the customer credit options * @Creation Date: August 12,2017 * @Author: sbaireddy * @Version: 1.0 */ import { Component, OnInit, OnDestroy } from '@angular/core'; import * as Constants from '../../shared/constants' import { CREDIT_OPTIONS } from '../../shared/form.constants'; import { SharedService } from '../../shared/shared.service'; @Component( { moduleId: module.id, selector: 'credit-options-cmp', templateUrl: 'credit-options.component.html', styleUrls: ['./credit-options.component.css'] }) export class CreditOptionsComponent implements OnInit { private COMPONENT_NAME: string = 'CreditOptionsComponent'; creditType: string = Constants.DEFAULT_CREDIT; creditOptions: any = {}; constructor(public sharedService: SharedService) { } /** * This function is used to initialize the directive/component after Angular * first displays the data-bound properties.It is invoked only once when the * directive is instantiated.It is invoked only once when the * directive is instantiated.Here it is initializing the cart & customer informations * @return void */ ngOnInit(): void { const METHOD_NAME: string = 'ngOnInit()'; // this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Loading credit options'); this.creditOptions = CREDIT_OPTIONS.filter(creditOption => creditOption); this.sharedService.creditChoice.subscribe((val: string) => { this.creditType = val; }); } /** * This function is used update credit choid using updateCreditChoice of a service * @param {any} creditOption contains valid credit details. * @return void */ updateCreditOption(creditOption: any): void { const METHOD_NAME: string = 'updateCreditOption()'; this.sharedService.updateCreditChoice(creditOption.creditType); } }