Dear Sir/Madam,


I am new to Angular.JS.


I want a part of my HTML Page to be updated with some data. For the data, I 
have written a service and this is returning the data correctly as fetched 
from the database. However, this is not getting displayed on the page.


I have written a OnInit(). However, OnInit() method is never getting fired.

The variables are referred in the corresponding HTML Files and should 
display the values as stored in these variables. Also, as the data changes, 
the listener should update the values.


Please help me solve this.


Thanks and Regards,
Partha


import { Component, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';

import { Currency } from '../currency.model';
import { CurrencyService } from '../currency.service';

@Component({
    selector: 'app-Currency-Statistics',
    templateUrl: './currencyStatistics.component.html',
    styleUrls: ['./currencyStatistics.component.css']
})
export class AppCurrencyStatisticsComponent implements OnInit {
  strActiveCurrencies = '';
  strDeletedRecords = '7';
  strLastUpdatedBy = 'partham';
  currencyList: Currency[] = [];
  private currencySubscription: Subscription;

  constructor(public currencyService: CurrencyService) {}

  ngOnInit() {
    this.strActiveCurrencies = this.currencyService.getRecordCount().toString();
    alert('Currency Count:' + this.strActiveCurrencies);
    this.currencySubscription = 
this.currencyService.getCurrencyUpdatedListener()
                    .subscribe( (currencies: Currency[]) => {
                                    this.currencyList = currencies;
                                    // this.refresh();
                                });
  }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to