How do I log out in angle 4?

-1

Good afternoon, I would like to know how do I log out in angle 4, as I am developing a dashboard and only need this requirement Thanks in advance.

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

import { NbMenuService, NbSidebarService } from '@nebular/theme';
import { UserService } from '../../../@core/data/users.service';
import { AnalyticsService } from '../../../@core/utils/analytics.service';

@Component({
  selector: 'ngx-header',
  styleUrls: ['./header.component.scss'],
  templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {


  @Input() position = 'normal';

  user: any;

  userMenu = [{ title: 'Profile' }, { title: 'Log out' }];

  constructor(private sidebarService: NbSidebarService,
              private menuService: NbMenuService,
              private userService: UserService,
              private analyticsService: AnalyticsService) {
  }

  ngOnInit() {
    this.userService.getUsers()
      .subscribe((users: any) => this.user = users.nick);
  }

  toggleSidebar(): boolean {
    this.sidebarService.toggle(true, 'menu-sidebar');
    return false;
  }

  toggleSettings(): boolean {
    this.sidebarService.toggle(false, 'settings-sidebar');
    return false;
  }

  goToHome() {
    this.menuService.navigateHome();
  }

  startSearch() {
    this.analyticsService.trackEvent('startSearch');
  }
}
    
asked by anonymous 20.04.2018 / 06:14

2 answers

0

You should have a route in your api to perform this man action. You can either clear the user and password in the Angular, or delete the scan token, this would solve your problem, but a route would be the right one.

    
25.04.2018 / 16:27
0

Good morning, this will depend on how you are logging in ... if it is with cookie or localstorage, a component can be created, where you could just use the TypeScript cleanup method and redirect if you are doing this via server, would have to make a method in your application and call an httprequest ... explain how your application is.

    
21.08.2018 / 13:11