Angular's toolbar has the ability to alter the appearance of my login interface

I am facing an issue with my final paper assignment regarding my Angular project and the Login component. I wanted to hide the toolbar component when there is no currentUser present in the system. Although I was able to achieve this using

<ng-content></ng-content>
in the Toolbar, I noticed that it changed the style of the Login component.

login.component.html

<div class="logo">
    <a href="https://www.cedupcriciuma.com.br/" target="_blank"><img class="iconLogo"
            src="../../../../assets/LogoCedup.png" alt="Logo"></a>
</div>
<div class="spinnerDiv">
...
...
...

toolbar-menu.component.html

<div>
...
...
...

app.component.html

<app-toolbar-menu >
    <router-outlet></router-outlet>
</app-toolbar-menu>

IMAGES OF THE APPLICATION How it should be

How it is

Thank you for your assistance!

Answer №1

It appears that the goal is to adjust the layout based on whether a user is logged in or not.

One approach to achieve this is by creating two layouts as shown below:

BaseLayoutComponent

@Component({
    selector: 'app-base-layout',
    template: `
        <router-outlet></router-outlet>
    `
})
export class BaseLayoutComponent implements OnInit {

    constructor() { }

    ngOnInit(): void {
    }

}

SiteLayoutComponent

@Component({
    selector: 'app-site-layout',
    template: `
        <app-header></app-header>
        <router-outlet></router-outlet>
    `
})
export class SiteLayoutComponent implements OnInit {

    constructor() { }

    ngOnInit(): void {
    }

}

You can then switch between them in your app-routing.module.ts like so:

const routes: Routes = [{
        path: '',
        component: SiteLayoutComponent,
        children: [
            { path: '', redirectTo: '/home', pathMatch: 'full' },
            { path: 'home', component: HomeComponent }
        ]
    },
    {
        path: '',
        component: BaseLayoutComponent,
        children: [
            {
                path: 'auth',
                loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule),
                canActivate: [NotLoggedInGuard]
            }
        ]
    },
    
];
  • The NotLoggedInGuard simply checks if the user is not logged in.

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

Limiting the Rate of Requests to a TCP Server using net.Server

I've been utilizing net.Server as my TCP server. Is there a way to impose a message rate limit? I managed to find solutions for enforcing rate limits in Express (express-rate-limit) and Websocket (websocket-rate-limit), but nothing specifically for ...

Is there a way to move the <hr> element closer to the content in the header section?

I am looking to move the closer to the content in the header. I attempted using position-absolute but the disappeared. This marks my inaugural project with bootstrap. <!-- Bootstrap-5 --> <link href="https://cdn.jsdelivr.net/npm/<a href="/ ...

Utilizing Angular 6's Mat-Table in a dynamic way

I am currently working on an Angular application that involves displaying data fetched from an API. The challenge I'm facing is that I do not have prior knowledge of the data I will be retrieving. Additionally, I need to create a model that can be use ...

Confirmation of successful form submission

I have created a form to collect user details. Once the form is submitted, the page reloads. I am looking to show a success message after the page reloads. <form name="myForm" class="contactus-template" method="post" onsubm ...

Fulfilling a pledge from an external source to postpone the implementation of the program

In my Angular service, there is an object called _mapView that gets initialized after the entire application and its dependencies are loaded. However, there is a possibility that users might interact with buttons or other elements triggering get-calls to t ...

Issue with displaying the correct size of column shortcodes in Wordpress

My column shortcode plugin doesn't seem to be working properly as the one_half column shortcodes are extending too far into the content area and wrapping onto the next line when placed side by side. What could be causing this issue? To see an example, ...

Can you explain the contrast between Angular 2 components and directives?

I have been having difficulty grasping the distinction between these two ideas within the framework. I am quite experienced with directives in AngularJS 1.x, and both components and directives in Angular 2 appear to be closely related to this concept... ...

The alignment of Bootstrap table cells is inconsistent

Trying to implement a fixed header table, but encountering issues with alignment table-fixed tbody { height: 300px; overflow-y: auto; width: 100%; } .table-fixed thead, .table-fixed tbody, .table-fixed tr, .table-fixed td, .tabl ...

Angular 6 - Unlocking the Secrets of Filtered Results

I need help accessing the filteredArray in my .ts component. Currently, it is only accessible within the ng-container. <ng-container *ngIf="(userList | filter: 'name' : value) as filteredArray"> <tr *ngFor="let user of filteredArray ...

Utilizing media queries and JQuery to display a variety of menus based on screen

I have created a hamburger menu specifically for smaller screens, and it is functioning properly on small screens. However, I am facing an issue where if the menu is not open before resizing the screen to a larger size, the menu does not show at all. When ...

Firefox exhibiting an additional pixel when hovering over dropdown menus

When using top: 100% to position a sub-menu dropdown below the main navigation bar on hover, there seems to be an issue in Firefox where the menu is pushed below the border of the menu causing a small gap. Interestingly, this works as expected in Webkit br ...

Is it possible to reset the value of an input field with type "number" similar to how it can be done with type "search"?

My Bootstrap 4 form includes various types of inputs, some for numbers, some for text, and others for email. I have managed to style the text inputs to display a cancel button inside with the following code: input[type="search"]::-webkit-search- ...

Angular's dependency injection gets disrupted by the use of lazy loading

I am facing a scenario where I have a module A, which is an npm package that needs to be used in module B. Module B is also an npm package that is utilized in an application. Module B is lazily loaded by the application. Within module A, I have the follo ...

Issues arise during Angular2 building process, such as failure to locate the name 'document' and unresolved references

Recently, I've been incorporating Jasmine unit tests into my Angular 2 project and made updates to some NPM packages. As a result, I've encountered two distinct errors that seem to be interconnected, so I thought it best to address both in one qu ...

Are you making the switch to Bootstrap 4 from Bootstrap 3?

Currently, I am utilizing bootstrap 3 in my project. Upon discovering that Bootstrap 4 is a significant overhaul of the entire Bootstrap project, I am contemplating whether it is essential to transition from version 3 to 4. Is there a compelling reason t ...

The JSON representation is not appearing for the newly introduced nested components

Building a nested component within another component and implementing two-way binding for dynamically added field values using the JSON pipe in the view. However, encountering an issue where the newly added values are not reflected in the JSON view. If yo ...

Transitioning one element's opacity to zero while concurrently increasing another element's opacity to replace it

There are a total of 3 div elements and 3 links included in this setup. The goal is to only display one div at any given time. Upon clicking on a link corresponding to a different div, the current one should fade out while the selected one fades in seamle ...

Images that are not aligned to the left

I'm really struggling with this issue that seems so simple. I am trying to create a grid layout of images like the following: [Image] [Image] | [ Big [Image] [Image] | Image ] Creating the grid with just images is not difficult for me, but th ...

Tips for incorporating null checks into a function in TypeScript

In my code, I have multiple functions that require a null check on an object before proceeding with certain actions or throwing an error if the object is null. Here is an example of what it looks like: interface SomeObject { doThingOne: () => string ...

designing an ornate border with CSS techniques

Can anyone offer guidance on how to achieve an engraved border effect using CSS with the color #505050? I have spent hours searching online with no luck finding a CSS solution. I could create it in Photoshop, but I am not proficient with that tool. ...