When I call a component in Angular it doesn't appears, and the home component still appears even when the endpoint changes

Rami

I've created a "student" component and when I called it it doesn't appears in the endpoint where it should be located! instead, the home component still appears even in the student endpoint (/student)

enter image description here enter image description here

Student component

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

@Component({
  selector: 'app-student',
  templateUrl: './student.component.html',
  styleUrls: ['./student.component.css']
})
export class StudentComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }

}
<p>student works!</p>

app.routing.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { StudentComponent } from './components/student/student.component';

const routes: Routes = [{ path: 'student', component: StudentComponent },];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}

app.component.html

<h1>Grade Management</h1>

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'GradeManagement_FrontEnd';
}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { StudentComponent } from './components/student/student.component';

@NgModule({
  declarations: [
    AppComponent,
    StudentComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Rami

Thank you all, I've fixed the problem by adding <router-outlet></router-outlet> to the

app.component.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

IF EXISTS command appears to be executing, even when condition doesn't exist?

Angular - Active route still appears when I am not on the route

Child Component doesn't rerender when state of parent component changes

when i click button,new button appears and it doesn't work

Div appears even when cookie policy is still in date

Component doesn't render when I test

Child component doesn't get updated when props changes

React component doesn't re-render when state changes

Call component method when model property changes

State changes but component doesn't update - ANGULAR

React doesn't call componentWillMount when render returns another component

Why 'theme' doesn't change in App.js when I call the hook function from another component

Angular - Parent component is in stuck when child component is still loading

How to Fire a Method When the Component Changes in Angular

Angular: Check when Output Variable in Component Changes?

Angular component is not updating UI when value changes

Angular Element Component doesn't update when I add object from property

The increaseSecondState function is re-rendering the child component even when i didn't pass it as a prop to the child component

Angular 2: When component A changes update component B

React Router doesn't show component when i refresh

UseEffect hook doesn't rerender the component when I update the state

Data appears when printed but doesn't show up in dataframe

Tableview Images doesn't load, but at times appears when scrolling

Scrollview doesn't move up when keyboard appears several times

Flutter List view builder doesn't shrink when Keyboard appears

Backend response value is empty when endpoint is called from React component even though network call shows response body

NoSuchElement exception even when element appears in Inspect

Why UICollectionView offset changes when keyboard appears

ActionBar appears when i press on Edittext and when i finish typing and close the keyboard it is still there