File tree Expand file tree Collapse file tree 7 files changed +37
-19
lines changed Expand file tree Collapse file tree 7 files changed +37
-19
lines changed Original file line number Diff line number Diff line change 1- import { Component } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { TranslateService } from '@ngx-translate/core' ;
33import { Meta , Title } from '@angular/platform-browser' ;
4-
54import { NavigationEnd , Router } from '@angular/router' ;
65import { AppConfig } from './config/app.config' ;
76import { MatSnackBar } from '@angular/material' ;
@@ -13,17 +12,19 @@ declare const Modernizr;
1312 templateUrl : './app.component.html'
1413} )
1514
16- export class AppComponent {
15+ export class AppComponent implements OnInit {
1716
18- isOnline = navigator . onLine ;
17+ isOnline : boolean ;
1918
2019 constructor ( private translateService : TranslateService ,
2120 private title : Title ,
2221 private meta : Meta ,
2322 private snackBar : MatSnackBar ,
2423 private router : Router ) {
24+ this . isOnline = navigator . onLine ;
25+ }
2526
26- this . translateService = translateService ;
27+ ngOnInit ( ) {
2728 this . translateService . setDefaultLang ( 'en' ) ;
2829 this . translateService . use ( 'en' ) ;
2930
Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ import {TranslateService} from '@ngx-translate/core';
88} )
99
1010export class FooterComponent {
11+
1112 currentLang : string ;
12- currentDate = Date . now ( ) ;
13+ currentDate : number ;
1314
1415 constructor ( private translateService : TranslateService ) {
1516 this . currentLang = this . translateService . currentLang ;
17+ this . currentDate = Date . now ( ) ;
1618 }
1719}
Original file line number Diff line number Diff line change 1- import { Component , Inject } from '@angular/core' ;
1+ import { Component , Inject , OnInit } from '@angular/core' ;
22import { TranslateService } from '@ngx-translate/core' ;
33
44import { APP_CONFIG , AppConfig } from '../../config/app.config' ;
@@ -11,7 +11,8 @@ import {ProgressBarService} from '../progress-bar.service';
1111 styleUrls : [ './nav.component.scss' ]
1212} )
1313
14- export class NavComponent {
14+ export class NavComponent implements OnInit {
15+
1516 appConfig : any ;
1617 menuItems : any [ ] ;
1718 progressBarMode : string ;
@@ -21,9 +22,11 @@ export class NavComponent {
2122 private progressBarService : ProgressBarService ,
2223 private translateService : TranslateService ) {
2324 this . appConfig = appConfig ;
24- this . loadMenus ( ) ;
2525 this . currentLang = this . translateService . currentLang ;
26+ }
2627
28+ ngOnInit ( ) {
29+ this . loadMenus ( ) ;
2730 this . progressBarService . updateProgressBar$ . subscribe ( ( mode : string ) => {
2831 this . progressBarMode = mode ;
2932 } ) ;
Original file line number Diff line number Diff line change 1- import { Component } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { LoggerService } from '../logger.service' ;
33import { Hero } from '../../heroes/shared/hero.model' ;
44import { FormControl } from '@angular/forms' ;
@@ -15,16 +15,19 @@ import {AppConfig} from '../../config/app.config';
1515 ]
1616} )
1717
18- export class SearchBarComponent {
19- defaultHeroes : Array < Hero > = [ ] ;
18+ export class SearchBarComponent implements OnInit {
19+
20+ defaultHeroes : Array < Hero > ;
2021 heroFormControl : FormControl ;
2122 filteredHeroes : any ;
22- heroesAutocomplete : any ;
2323
2424 constructor ( private heroService : HeroService ,
2525 private router : Router ) {
26+ this . defaultHeroes = [ ] ;
2627 this . heroFormControl = new FormControl ( ) ;
28+ }
2729
30+ ngOnInit ( ) {
2831 this . heroService . getAllHeroes ( ) . subscribe ( ( heroes : Array < Hero > ) => {
2932 this . defaultHeroes = heroes . filter ( hero => hero [ 'default' ] ) ;
3033
Original file line number Diff line number Diff line change 1- import { Component } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { Hero } from '../shared/hero.model' ;
33import { HeroService } from '../shared/hero.service' ;
44import { ActivatedRoute } from '@angular/router' ;
@@ -9,12 +9,16 @@ import {ActivatedRoute} from '@angular/router';
99 styleUrls : [ './hero-detail.component.scss' ]
1010} )
1111
12- export class HeroDetailComponent {
12+ export class HeroDetailComponent implements OnInit {
13+
1314 hero : Hero ;
1415 canVote : boolean ;
1516
1617 constructor ( private heroService : HeroService ,
1718 private activatedRoute : ActivatedRoute ) {
19+ }
20+
21+ ngOnInit ( ) {
1822 this . activatedRoute . params . subscribe ( ( params : any ) => {
1923 if ( params [ 'id' ] ) {
2024 this . heroService . getHeroById ( params [ 'id' ] ) . subscribe ( ( hero : Hero ) => {
Original file line number Diff line number Diff line change 1- import { Component , ViewChild } from '@angular/core' ;
1+ import { Component , OnInit , ViewChild } from '@angular/core' ;
22import { Hero } from '../shared/hero.model' ;
33import { HeroService } from '../shared/hero.service' ;
44import { FormBuilder , FormGroup , Validators } from '@angular/forms' ;
@@ -23,7 +23,8 @@ export class RemoveHeroDialogComponent {
2323 styleUrls : [ './hero-list.component.scss' ]
2424} )
2525
26- export class HeroListComponent {
26+ export class HeroListComponent implements OnInit {
27+
2728 heroes : Hero [ ] ;
2829 newHeroForm : FormGroup ;
2930 canVote = false ;
@@ -40,7 +41,9 @@ export class HeroListComponent {
4041 'name' : [ '' , [ Validators . required ] ] ,
4142 'alterEgo' : [ '' , [ Validators . required ] ]
4243 } ) ;
44+ }
4345
46+ ngOnInit ( ) {
4447 this . heroService . getAllHeroes ( ) . subscribe ( ( heroes : Array < Hero > ) => {
4548 this . heroes = heroes . sort ( ( a , b ) => {
4649 return b . likes - a . likes ;
Original file line number Diff line number Diff line change 1- import { Component } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { Hero } from '../shared/hero.model' ;
33import { HeroService } from '../shared/hero.service' ;
44import { AppConfig } from '../../config/app.config' ;
@@ -9,15 +9,17 @@ import {Router} from '@angular/router';
99 templateUrl : './hero-top.component.html' ,
1010 styleUrls : [ './hero-top.component.scss' ]
1111} )
12- export class HeroTopComponent {
12+ export class HeroTopComponent implements OnInit {
1313
1414 heroes : Hero [ ] = null ;
1515 canVote = false ;
1616
1717 constructor ( private heroService : HeroService ,
1818 private router : Router ) {
1919 this . canVote = this . heroService . checkIfUserCanVote ( ) ;
20+ }
2021
22+ ngOnInit ( ) {
2123 this . heroService . getAllHeroes ( ) . subscribe ( ( heroes ) => {
2224 this . heroes = heroes . sort ( ( a , b ) => {
2325 return b . likes - a . likes ;
You can’t perform that action at this time.
0 commit comments