import { Component, Input, OnInit, OnChanges, OnDestroy } from '@angular/core'; import * as Constants from '../../../../shared/constants'; import { IOrderItemFeature, IOrderItemRateplan} from '../../../../shared/modal/common'; import { SharedService } from '../../../../shared/shared.service'; @Component( { selector: 'feature-cmp', moduleId: module.id, templateUrl: 'feature.component.html' }) export class FeatureComponent implements OnInit, OnChanges, OnDestroy { private COMPONENT_NAME: string = 'FeatureComponent'; @Input() orderItems: IOrderItemFeature[]; @Input() plan: IOrderItemRateplan; @Input() val: Number; storeId: number; rtStoreId: number = Constants.STORE_ID_RT; accLevelFeature: string = Constants.FEATURE_GRP_NAME_ACC; subLevelFeature: string = Constants.FEATURE_GRP_NAME_SUB; prodLevelFeature: string = Constants.FEATURE_GRP_NAME_PROD; /** * 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. * @returns void */ constructor(public sharedService: SharedService) {} ngOnInit(): void { const METHOD_NAME: string = 'ngOnInit()'; } /** * This function is called whenever one or more data-bound input properties change * @returns void */ ngOnChanges(): void { const METHOD_NAME: string = 'ngOnChanges()'; this.sharedService.storeId.subscribe((val: number) => {this.storeId = val; }); } /** * Cleanup just before Angular destroys the directive/component. * Unsubscribe Observables and detach event handlers to avoid memory leaks. * @returns void */ ngOnDestroy(): void { const METHOD_NAME: string = 'ngOnDestroy()'; } }