File tree Expand file tree Collapse file tree 4 files changed +39
-12
lines changed Expand file tree Collapse file tree 4 files changed +39
-12
lines changed Original file line number Diff line number Diff line change 1- < div class ="navbar-header ">
2- < a class ="navbar-brand " href ="# "> Auth0 - Angular 2</ a >
3- < button class ="btn btn-primary btn-margin " (click) ="auth.login() " *ngIf ="!auth.authenticated() "> Log In</ button >
4- < button class ="btn btn-primary btn-margin " (click) ="auth.logout() " *ngIf ="auth.authenticated() "> Log Out</ button >
5- </ div >
1+ < app-header > </ app-header >
62< router-outlet > </ router-outlet >
Original file line number Diff line number Diff line change 11import { Component } from '@angular/core' ;
2- import { Auth } from './auth/auth.service' ;
32
43@Component ( {
54 selector : 'app-root' ,
65 templateUrl : './app.component.html' ,
76 styleUrls : [ './app.component.css' ]
87} )
98export class AppComponent {
10- constructor ( private auth : Auth ) { }
9+
1110}
Original file line number Diff line number Diff line change 1- < p >
2- header works!
3- </ p >
1+ < header >
2+ < a class ="logo " href ="# " routerLink ="/ " > Auth0 + Angular 2</ a >
3+ < button class ="login-btn " (click) ="auth.login() " *ngIf ="!auth.authenticated() "> Log In</ button >
4+
5+ < ul class ="user-menu " *ngIf ="auth.authenticated() ">
6+ < li > < a href ="# " routerLink ="/dashboard "> Dashboard</ a > </ li >
7+ < li > < a href ="# " routerLink ="/user-profile "> My Profile</ a > </ li >
8+ < button class ="logout-btn " (click) ="auth.logout() "> Log Out</ button >
9+ </ ul >
10+ </ header >
Original file line number Diff line number Diff line change 11import { Component , OnInit } from '@angular/core' ;
2+ import { Auth } from '../../auth/auth.service' ;
23
34@Component ( {
45 selector : 'app-header' ,
56 templateUrl : './header.component.html' ,
6- styles : [ ]
7+ styles : [
8+ `header {
9+ background: #eee;
10+ width: 100%;
11+ padding: 20px 0;
12+ }
13+ .logo {
14+ margin: 0 20px;
15+ font-size: 18px;
16+ font-weight: bold;
17+ text-decoration: none;
18+ }
19+ .login-btn,
20+ .logout-btn {
21+ float: right;
22+ margin: 0 20px;
23+ }
24+ .user-menu {
25+ float: right;
26+ margin: 0;
27+ }
28+ .user-menu > li {
29+ display: inline-block;
30+ }`
31+ ]
732} )
833export class HeaderComponent implements OnInit {
934
10- constructor ( ) { }
35+ constructor ( private auth : Auth ) { }
1136
1237 ngOnInit ( ) {
1338 }
You can’t perform that action at this time.
0 commit comments