Hi I am completely new to Angular and I tried other stack overflow answers also. Currently I am working on angular 4 project.
As per my project, I need to create designs only right now using angular and its routing.
What I actually want is a login page, once key in login button need to go to another page with horizontal left side navbar along with its first child active and by clicking navbar menus, only content needs to change and the navbar remains static for all other pages(except login only).
After go through lot of videos finally, I created a login page. I wrote the codes for Login page in appcomponent.html and I gave routerlink to the button login to open up the login page. my routing working, once I click login my url changes from http://localhost:4200/
to http://localhost:4200/sidebar
but my page still shows login page designs only.
Codes are below: index.html
<body >
<app-root></app-root>
</body>
app.component.ts
import { Component } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { SidebarComponent } from './sidebar/sidebar.component';
const appRoutes: Routes = [
{ path:'sidebar', component: SidebarComponent }
];
@NgModule({
declarations: [
AppComponent,
SidebarComponent,
],
imports: [
RouterModule.forRoot(appRoutes),
BrowserModule,
FormsModule,
HttpModule
],
exports: [RouterModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.html
I give only login button code where I gave router link as there is lot of codes
<div class="col-md-12 col-md-push-6 text-center">
<a routerLink="/sidebar" routerLinkActive="active"> <button id="Enter" class="btn btn-primary btn-block btn-flat fa fa-sign-in" > Log-In</button></a>
</div>
and I give <router-outlet></router-outlet>
inside my nav bar page where I want to render content.
As currently my one not working I changed the sidebar.htlm page coding as <h1> TESTING </h1>
only. What I did wrong?. Kindly help.