Talk about it! I have a big question and I can not solve it. I'm developing an application for my college's TCC in Angular. I have a menu and within that menu there are options to navigate the site, but instead of changing pages, I would like this new page to be loaded into a div that is in the same content, I will post the code.
Here is my file named index.component.html that has the menu.
<nav class="menu" tabindex="0">
<div class="smartphone"></div>
<header class="avatar"></header>
<ul>
<li><a [routerLink]="['/cadTel']">Cadastro Tele</a></li>
<li><a [routerLink]="['/config']">Configuracoes</a></li>
</ul>
</nav>
<main>
<div class="carregaPaginas">
<span>Tem um texto aqui pra teste</span>
</div>
</main>
I would like to know how to do this by clicking on the Menu Option Register Tele load the contents inside the div loads Pages.
Tks !!
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from "@angular/http";
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DataFormModule } from './pages/data-form/data-form.module';
import { HttpClientModule } from '@angular/common/http';
import { LoginComponent } from './pages/login/login.component';
import { Error404Component } from './pages/error404/error404.component';
import { IndexComponent } from './pages/index/index.component';
@NgModule({
declarations: [
AppComponent,
LoginComponent,
Error404Component,
IndexComponent,
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
FormsModule,
HttpModule,
ReactiveFormsModule,
DataFormModule
], providers: [], bootstrap: [AppComponent] }) export class AppModule {}
and my app.component.html
<router-outlet></router-outlet>
I need to start in the login / login that comes from LoginComponent and that when I log in go to the IndexComponent (/ index) and within the index I can use the route option that I asked up there to load inside the page load.
my app-routing.module.ts file
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DataFormComponent } from './pages/data-form/data-form.component';
import { LoginComponent } from './pages/login/login.component';
import { IndexComponent } from './pages/index/index.component';
import { Error404Component } from './pages/error404/error404.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'login'},
{ path: 'login', component: LoginComponent },
{ path: 'dataForm', component: DataFormComponent },
{ path: '**', component: Error404Component }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }