File

src/app/app.component.ts

Metadata

selector app-root
styleUrls app.component.css
templateUrl app.component.html

Constructor

constructor(authService: AuthService)

Properties

jwtHelper
jwtHelper: JwtHelper
import { Component, OnInit } from '@angular/core';
import { AuthService } from './_services/auth.service';
import { JwtHelper } from 'angular2-jwt';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent implements OnInit {
  jwtHelper: JwtHelper = new JwtHelper();

  constructor(private authService: AuthService) {

  }
  ngOnInit() {
    //to populate name on navbar after every refresh if token is valid
    const token = localStorage.getItem('token');
    if (token) {
      this.authService.decodedToken = this.jwtHelper.decodeToken(token);
    }
  }
}

results matching ""

    No results matching ""