My Angular7 app.component.html file is not displaying the routing. What could be the issue?

After implementing the code in app.component.html in Angular 7 like this:

    <div id="wrapper">

    <header id="header-container" class="fullwidth">

    <div id="header">
    <div class="container">

        <div class="left-side">

                <div id="logo">
                <a href="index.html"><img src="images/logo.png" alt=""></a>
                </div>
                <nav id="navigation">
                <ul id="responsive">

                    <li><a [routerLink]="/Home" class="current">Home</a></li>
                    <li><a [routerLink]="/Projects">Projects</a>
                    <ul class="dropdown-nav">
                        <li><a href="#">Post Project</a></li>
                </ul>
                </nav>

            </div>


            <div class="right-side">

                <div class="header-widget hide-on-mobile">

                    <div class="header-notifications">

                        <div class="header-notifications-trigger">
                            <a href="#"><i class="icon-feather-bell"></i><span>4</span></a>
                        </div>

                        <div class="header-notifications-dropdown">

                            <div class="header-notifications-headline">
                                <h4>Notifications</h4>
                                <button class="mark-as-read ripple-effect-dark" title="Mark all as read" data-tippy-placement="left">
                                    <i class="icon-feather-check-square"></i>
                                </button>
                            </div>

                            <div class="header-notifications-content">
                                <div class="header-notifications-scroll" data-simplebar>
                                    <ul>
                                        <li class="notifications-not-read">
                                            <a href="dashboard-manage-candidates.html">
                                                <span class="notification-icon"><i class="icon-material-outline-group"></i></span>
                                                <span class="notification-text">
                                                    <strong>Michael Shannah</strong> applied for a job <span class="color">Full Stack Software Engineer</span>
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="dashboard-manage-bidders.html">
                                                <span class="notification-icon"><i class=" icon-material-outline-gavel"></i></span>
                                                <span class="notification-text">
                                                    <strong>Gilbert Allanis</strong> placed a bid on your <span class="color">iOS App Development</span> project
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="dashboard-manage-jobs.html">
                                                <span class="notification-icon"><i class="icon-material-outline-autorenew"></i></span>
                                                <span class="notification-text">
                                                    Your job listing <span class="color">Full Stack PHP Developer</span> is expiring.
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="dashboard-manage-candidates.html">
                                                <span class="notification-icon"><i class="icon-material-outline-group"></i></span>
                                                <span class="notification-text">
                                                    <strong>Sindy Forrest</strong> applied for a job <span class="color">Full Stack Software Engineer</span>
                                                </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>

                        </div>

                    </div>

                    <div class="header-notifications">
                        <div class="header-notifications-trigger">
                            <a href="#"><i class="icon-feather-mail"></i><span>3</span></a>
                        </div>

                        <div class="header-notifications-dropdown">

                            <div class="header-notifications-headline">
                                <h4>Messages</h4>
                                <button class="mark-as-read ripple-effect-dark" title="Mark all as read" data-tippy-placement="left">
                                    <i class="icon-feather-check-square"></i>
                                </button>
                            </div>

                            <div class="header-notifications-content">
                                <div class="header-notifications-scroll" data-simplebar>
                                    <ul>
                                        <li class="notifications-not-read">
                                            <a href="dashboard-messages.html">
                                                <span class="notification-avatar status-online"><img src="assets/images/user-avatar-small-03.jpg" alt=""></span>
                                                <div class="notification-text">
                                                    <strong>David Peterson</strong>
                                                    <p class="notification-msg-text">Thanks for reaching out. I'm quite busy right now on many...</p>
                                                    <span class="color">4 hours ago</span>
                                                </div>
                                            </a>
                                        </li>

                                        <li class="notifications-not-read">
                                            <a href="dashboard-messages.html">
                                                <span class="notification-avatar status-offline"><img src="assets/images/user-avatar-small-02.jpg" alt=""></span>
                                                <div class="notification-text">
                                                    <strong>Sindy Forest</strong>
                                                    <p class="notification-msg-text">Hi Tom! Hate to break it to you, but I'm actually on vacation until...</p>
                                                    <span class="color">Yesterday</span>
                                                </div>
                                            </a>
                                        </li>

                                        <li class="notifications-not-read">
                                            <a href="dashboard-messages.html">
                                                <span class="notification-avatar status-online"><img src="assets/images/user-avatar-placeholder.png" alt=""></span>
                                                <div class="notification-text">
                                                    <strong>Marcin Kowalski</strong>
                                                    <p class="notification-msg-text">I received payment. Thanks for cooperation!</p>
                                                    <span class="color">Yesterday</span>
                                                </div>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>

                            <a href="dashboard-messages.html" class="header-notifications-button ripple-effect button-sliding-icon">View All Messages<i class="icon-material-outline-arrow-right-alt"></i></a>
                        </div>
                    </div>

                </div>

                <div class="header-widget">

                    <div class="header-notifications user-menu">
                        <div class="header-notifications-trigger">
                            <a href="#"><div class="user-avatar status-online"><img src="assets/images/user-avatar-small-01.jpg" alt=""></div></a>
                        </div>

                        <div class="header-notifications-dropdown">

                            <div class="user-status">

                                <div class="user-details">
                                    <div class="user-avatar status-online"><img src="assets/images/user-avatar-small-01.jpg" alt=""></div>
                                    <div class="user-name">
                                        Tom Smith <span>Freelancer</span>
                                    </div>
                                </div>

                                <div class="status-switch" id="snackbar-user-status">
                                    <label class="user-online current-status">Online</label>
                                    <label class="user-invisible">Invisible</label>
                                    <span class="status-indicator" aria-hidden="true"></span>
                                </div>  
                        </div>

                        <ul class="user-menu-small-nav">
                            <li><a href="dashboard.html"><i class="icon-material-outline-dashboard"></i> Dashboard</a></li>
                            <li><a href="dashboard-settings.html"><i class="icon-material-outline-settings"></i> Settings</a></li>
                            <li><a href="index-logged-out.html"><i class="icon-material-outline-power-settings-new"></i> Logout</a></li>
                        </ul>

                        </div>
                    </div>

                </div>

                <span class="mmenu-trigger">
                    <button class="hamburger hamburger--collapse" type="button">
                        <span class="hamburger-box">
                            <span class="hamburger-inner"></span>
                        </span>
                    </button>
                </span>

            </div>

        </div>
        </div>

    </header>
    <!-- Header Container / End -->
    <router-outlet>
    </router-outlet>
    <app-messages></app-messages>

In the app.module.ts, we declare:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { RouterModule, Routes } from '@angular/router';
    import { AppComponent } from './app.component';
    import { ProjectsComponent } from './submenu/projects.component';
    import { FreelancerComponent } from './submenu/freelancer.component';
    import { LoginComponent } from './user/signin/login.component';
    import { LogoutComponent } from './user/signout/logout.component';
    import { HomeComponent } from './home/home.component';

    const routes: Routes = [
      { path: 'projects', component: ProjectsComponent },
      { path: 'home', component: HomeComponent },
      { path: '', redirectTo: '/home', pathMatch: 'full' }
    ];

    @NgModule({
      declarations: [
        AppComponent,
        LoginComponent,
        LogoutComponent,
        HomeComponent
      ],
      imports: [
        BrowserModule,
        RouterModule.forRoot(routes)
      ],
      exports: [ RouterModule ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

And in the app-routing.module.ts:

    import { NgModule } from '@angular/core';
    import { RouterModule, Routes } from '@angular/router';
    import { ProjectsComponent } from './submenu/Projects.component'; 
    import { HomeComponent } from './home/Home.component'; 

    const routes: Routes = [
          { path: '', redirectTo:'/home', pathMatch: 'full'},
          { path: 'home', component: HomeComponent },
          { path: 'projects', component: ProjectsComponent }
    ];

    export const RoutesProvider = RouterModule.forRoot(routes);
    export class AppRoutingModule { }

Despite following these steps outlined above, a blank screen appears instead of the Navigation menus.

To illustrate the issue further, here is an image showing the blank screen:

Snapshot demonstrating the empty space where navigation menus should be displayed

This question arises after examining a similar query on Stack Overflow titled "Why my file app.component.html is not working?"

You are dealing with a critical problem in Angular 7 as an Angular Developer, seeking assistance with resolving it.

Answer №1

There are several possible explanations for this issue.

Firstly, it may be that your ProjectsComponent has not been properly declared in the code.

 @NgModule({
      declarations: [
        AppComponent,
        LoginComponent,
        LogoutComponent,
        HomeComponent,
        ProjectsComponent
      ],

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trouble with triggering HTML5 FileReader() functions

I'm having trouble determining why neither readSuccess() nor readFailure() are being executed in the code snippet below: function readMyFile(){ var reader = new FileReader(); reader.onload = readSuccess; reader.onerror = readFailure; ...

Leveraging AJAX for implementing PHP scripts

While I may not be an MVC model expert, I'm trying to keep my page design separate from my logic in order to simplify things. I have already created a basic template and now I want hyperlinks to open PHP files within the same page. For example: Next ...

The background image fails to display properly on the server in Next.js

Hello, I'm currently using NextJs and I have a challenge. I want to set a background image on the body element that is rendered server-side. Below you'll find my code snippets: First, here is my App.js: import BodyStyle from '@components/Bo ...

What is the process of implementing FFT in node.js?

Struggling with implementing FFT in node.js is proving to be quite challenging for me at the moment. Despite experimenting with three different libraries, I find them all poorly documented, which only adds to the complexity of the task. My current setup i ...

Issue with setting innerHTML of element in AngularJS app upon ng-click event

Look at this block of HTML: <div class="custom-select"> <div class="custom-select-placeholder"> <span id="placeholder-pages">Display all items</span> </div> <ul class="custom-select- ...

Encountering difficulties with properly storing an array in MongoDB using Node.js and Mongoose

Can you point me in the right direction on how to properly store an array of data in mongodb using node/mongoose? I'm currently facing an issue where all my data is being saved as the first value in the array. Here's a snippet of my code: const ...

Is there a way to position one DIV behind another?

Hey, I'm working on my first project and running into some trouble with divs. I'm trying to position the firework behind the central text but can't figure it out. Can anyone lend a hand? I need to add more details in order to submit the que ...

Feeling overwhelmed by the potential capabilities of Angular Firestore

Seeking clarification as I am struggling to understand the usage of Angular and Firestore. Recently delved into Google Firebase and attempted CRUD operations with Firestore. What sets apart this library from others? import { Firestore } from '@angul ...

Combine angular ui router templates using grunt into a single file

Currently, I am working on an angular-ui-router project that consists of 150 files scattered all over. My goal is to create a grunt task that will merge all these files into a single index.html file structured like this: <script type="text/ng-template" ...

Facing an issue with webpack-dev-server where it displays a blank screen

Hello! I am currently in the process of creating my first MERN stack application, using Webpack as the build tool. The main objective is to have Express serving the APIs for the app and webpack-dev-server handling the static content (from my static directo ...

Learn how to use Javascript and ASP.NET to refresh the parent page in Mozilla Firefox browser

The code window.opener.location.reload(); works well in Internet Explorer, but it doesn't refresh the parent page in Mozilla Firefox. Can someone please advise me on how to refresh the parent page in a way that is cross-browser compatible? Here is th ...

Regular expression that can be used to extract information from a text file by filtering and returning only

When I open a text file, it contains several lines like the examples below. surname australia enter name j.jonhs enter name j.cause enter name f.london enter I am seeking assistance to modify the code snippet below so that it captures the first line m ...

Update the picture displayed in the parent div when it is in an

My code currently changes the image when a parent div is in an active state, but I'm struggling to figure out how to revert it back to the original image when clicked again. I attempted to use 'return false' at the end of the script, but it ...

Tips for minimizing padding in X-Range graphs

Is there a way to reduce the overall height of my X-Range chart by adjusting the padding on the Y axis around each series? I have experimented with different properties, such as adding groupPadding: 0, pointPadding: 0, and other parameters using this jsfi ...

What is the process for incorporating attribute values when constructing XML with fast-xml-parser?

Latest fast-xml-parser update: version 4.3.6 Description I'm trying to incorporate an xml attribute (tokenized="true") in this format : <custom-tag tokenized="true">test test &gt; 14</custom-tag> Input Code var def ...

Expo - Cli installation issue: encountering difficulties in installing the Expo CLI

Whenever I attempt to launch expo, it prompts me to install it. However, after installing it, I receive a message indicating that it has been successfully installed, only to be told again to install it. ...

What is the best way to retrieve error messages from a transaction with ethers.js?

Incorporating a custom error in my Solidity contract: error Documents__AlreadyExist(string hash); The modifier I utilize is as follows: modifier alreadyExist(string memory hash) { if (s_documentsHashes[hash]) { revert Documents__AlreadyExi ...

Encountering an error in resolving symbol values statically within the Angular module

Following a helpful guide, I have created the module below: @NgModule({ // ... }) export class MatchMediaModule { private static forRootHasAlreadyBeenCalled: boolean = false; // This method ensures that the providers of the feature module ar ...

JavaScript implementation of Ancient Egyptian Multiplication using PHP code

Let's dive into the algorithm. If we have two integers, A and B (remember, only integers), that need to be multiplied, here is how it works: we continuously multiply A by 2 and divide B by 2 until B cannot be divided any further, or in other words, un ...

Node.js encountering an empty array from an API request

In the 'product.js' file, there seems to be an issue with the API call '/achaar/products/1'. The value of val is empty when logging it in the console. Other API calls like '/achaar/products' are functioning correctly, but spec ...