add component page

parent e9c8fbd9
...@@ -103,5 +103,8 @@ ...@@ -103,5 +103,8 @@
"@schematics/angular:directive": { "@schematics/angular:directive": {
"prefix": "app" "prefix": "app"
} }
},
"cli": {
"analytics": "9ab085ba-bb22-4e92-92f7-a6b2e0ff105f"
} }
} }
\ No newline at end of file
import { NgModule } from '@angular/core'; import { NgModule } from "@angular/core";
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from "@angular/router";
import { AuthGuard } from './shared/guards';
import { HomeComponent } from './home/home.component';
import { AuthGuard } from "./shared/guards";
import { HomeComponent } from "./home/home.component";
import { TopicComponent } from "./topic/topic.component";
import { CreateTopicComponent } from "./create-topic/create-topic.component";
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: "",
component: HomeComponent, component: HomeComponent,
canActivate: [AuthGuard], canActivate: [AuthGuard],
}, },
{
path: "/topic",
component: TopicComponent
},
{
path: "/create",
component: CreateTopicComponent
},
,
{
path: "second-component",
component: SecondComponent
},
{ {
path: 'auth', path: "auth",
loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule), loadChildren: () => import("./auth/auth.module").then((m) => m.AuthModule),
}, },
{ {
path: 'admin', path: "admin",
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule), loadChildren: () =>
import("./admin/admin.module").then((m) => m.AdminModule),
}, },
]; ];
......
...@@ -12,6 +12,8 @@ import { AppRoutingModule } from './app-routing.module'; ...@@ -12,6 +12,8 @@ import { AppRoutingModule } from './app-routing.module';
import { HeaderComponent } from './header/header.component'; import { HeaderComponent } from './header/header.component';
import { HomeComponent } from './home/home.component'; import { HomeComponent } from './home/home.component';
import { AuthService } from './shared/services'; import { AuthService } from './shared/services';
import { TopicComponent } from './topic/topic.component';
import { CreateTopicComponent } from './create-topic/create-topic.component';
export function appInitializerFactory(authService: AuthService) { export function appInitializerFactory(authService: AuthService) {
return () => authService.checkTheUserOnTheFirstLoad(); return () => authService.checkTheUserOnTheFirstLoad();
...@@ -19,7 +21,7 @@ export function appInitializerFactory(authService: AuthService) { ...@@ -19,7 +21,7 @@ export function appInitializerFactory(authService: AuthService) {
@NgModule({ @NgModule({
imports: [BrowserAnimationsModule, HttpClientModule, SharedModule, AppRoutingModule], imports: [BrowserAnimationsModule, HttpClientModule, SharedModule, AppRoutingModule],
declarations: [AppComponent, HeaderComponent, HomeComponent], declarations: [AppComponent, HeaderComponent, HomeComponent, TopicComponent, CreateTopicComponent],
providers: [ providers: [
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CreateTopicComponent } from './create-topic.component';
describe('CreateTopicComponent', () => {
let component: CreateTopicComponent;
let fixture: ComponentFixture<CreateTopicComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateTopicComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CreateTopicComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-create-topic',
templateUrl: './create-topic.component.html',
styleUrls: ['./create-topic.component.css']
})
export class CreateTopicComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<span class="example-spacer"></span> <span class="example-spacer"></span>
<a class="links side" routerLink="/auth/login" *ngIf="!user">Login</a> <a class="links side" routerLink="/auth/login" *ngIf="!user">Login</a>
<div> <div>
<a class="links side" *ngIf="user" routerLink="/topic">Topic</a>
<a class="links side" *ngIf="user" routerLink="/create">Create topic</a>
<a class="links side" *ngIf="user" [matMenuTriggerFor]="menu"> <a class="links side" *ngIf="user" [matMenuTriggerFor]="menu">
<mat-icon>account_circle</mat-icon>{{ user.fullname }} <mat-icon>account_circle</mat-icon>{{ user.fullname }}
</a> </a>
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TopicComponent } from './topic.component';
describe('TopicComponent', () => {
let component: TopicComponent;
let fixture: ComponentFixture<TopicComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TopicComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TopicComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-topic',
templateUrl: './topic.component.html',
styleUrls: ['./topic.component.css']
})
export class TopicComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment