Navigate to a different page in AngularJS using ngRoute without utilizing ng-view

I have a web application dashboard with a common header across all HTML files, including the profile page, page 1, and SignIn. However, I want the SignIn page to be different without the common header. How can I redirect to signin.html without using ng-view or the common header?

var app=angular.module('single-page-app',['ngRoute']);
app.config(function($routeProvider,$locationProvider){
    //HTML5 Location # remove
    $locationProvider.html5Mode({
          enabled: true,
          requireBase: false
    });
      $routeProvider
          .when('/profile',{
                templateUrl: 'profile.html',
                controller:'profilecntrl'
          })
          .when('/page1',{
                templateUrl: 'page1.html',
                controller:'singlecntrl'
          }).
          when('/signIn',{
                templateUrl:'signIn.html'
          });

});
app.controller('MainController',function($scope){

});

My main Header file HTML is as follows:

 <!-- HEADER AND NAVBAR -->
        <header>
            <nav class="navbar navbar-default">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand" href="/">Angular Routing</a>
                </div>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="/profile">Profile</a></li>
                    <li><a href="/page1">Page 1</a></li>
                    <li><a href="/signIn">Sign In</a></li>
                </ul>
            </div>
            </nav>
        </header>

        <!-- MAIN CONTENT AND INJECTED VIEWS -->
            <div ng-view=""></div>

In a separate Sign In HTML file where ng-view and the Header are not included, you can still redirect to signIn.html using ng-Route.

Answer №1

If the user is on the sign-in page, you have the option to hide the header.

HTML:

<header ng-if="currentPage !== '/signIn'">
        <nav class="navbar navbar-default">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" href="/">Angular Routing</a>
            </div>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/profile">Profile</a></li>
                <li><a href="/page1">Page 1</a></li>
                <li><a href="/signIn">Sign In</a></li>
            </ul>
        </div>
        </nav>
    </header>

Controller:

app.controller('MainController',function($scope, $location){
    $scope.currentPage = $location.path();
});

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

Attempting to understand how to retrieve specific items from my MongoDB Database that are associated with a particular user based on their ID

I've been attempting to retrieve specific items (Portfolio pics) that have been submitted by a user from my Mongo Database. However, when I checked the extracted items using Console logs, it seems to display all portfolio pieces for every user instead ...

Having trouble retrieving JSON data using http.get method, as the status returned is -1

I'm a beginner in AngularJS. I'm attempting to retrieve JSON data in my code using $http.get, but it's throwing an error and the status is showing as -1. What could be causing this issue? RecordApp.factory('recordaccess', [' ...

Update the appearance of a cell if the value within it is equal to zero

I have discovered a way to achieve this using inputs. input[value="0"] { background-color:#F7ECEC; color:#f00;} Now, I am looking for assistance in applying the same concept to table cells. Can anyone provide guidance? Thank you. ...

The jQuery selector for input[type=text]:nth-child(2) is malfunctioning

I cannot utilize the ids or class names linked to the inputs because they are randomly generated on input. Here is how the render appears: <div class='dateSearch'> <label>Label 1</label> <input type='text' id=& ...

Why won't NextJS Image elements render on iOS 16 when they are not in the viewport initially?

I opted to implement NextJS for enhanced routing capabilities and image optimization. However, I encountered an issue with certain images failing to load properly on iOS devices. The problem arises within a scrollable horizontal container featuring Product ...

Identifying the completion of scrolling within a container

I'm facing a challenge with my dynamic website that has numerous blog posts. My goal is to initially load only four posts and then add another four as the user scrolls to the end of the page. While I have figured out how to handle this on the backend, ...

Exploring the contrasts between one-way binding and two-way binding within AngularJS

Can you please elaborate on the distinction between One-way Data Binding and Two-way Data Binding, providing an example of each and explaining when we would use them? ...

angular ensuring seamless synchronization of objects across the application

This question pertains to both angular and javascript. In our angular app, we have numerous objects from the backend that need to remain synchronized. I am facing challenges in establishing efficient data bindings to ensure this synchronization throughout ...

Create a series of canvas lines connecting all divs that share a common class identifier

Currently, I am in the process of creating a document that will establish a tree-type graph based on user input. My goal is to link styled divs with canvas lines to show their connection to the parent div. I have been utilizing .getBoundingClientRect() to ...

Is there a way to access a comprehensive list of all the set-up WebApi routes within asp.net MVC?

I am currently working on passing configuration values to initialize a single page AngularJs application embedded within an MVC application that makes use of WebApi (as shown below in the Razor view, achieved by inheriting a BasePage and injecting a Serial ...

Displaying errors in AngularJS form submission

I am currently using an AngularJS step wizard and within the form for the initial step, I would like validation errors to only appear when the user attempts to submit. At the moment, the error message displays as soon as the user navigates to the step, but ...

The ng-model feature is unable to properly save data within a nested ng-repeat function for a 2-dimensional array

I'm currently working with a nested ng-repeat on a 2d array and have added ng-model to the third ng-repeat. However, I am encountering an issue where my ng-model is not properly storing the data within the object. JavaScript Code emrService .getDat ...

What could be causing this error in a new Next.js application?

After multiple attempts, my frustration and disappointment in myself are causing a headache. Can someone please assist me? I am trying to create an app using the following command: npx create-next-app@latest --ts Immediately after running next dev, I enco ...

Enhancing serialized form with additional information through an ajax request

I'm currently facing an issue with adding additional data to my serialized form string. The situation is that I have a form with a set of fields called "Services", and users are able to add as many services as they want dynamically using a button in t ...

Implementing Next.js in a live production environment

I've been using next.js for some time now, but I'm still trying to wrap my head around how it operates in a production environment. As far as I understand it, when a request is made to the server, the server retrieves the requested page from the ...

Use markdown links instead of html hyperlinks

I encountered a scenario where I have a string formatted like this: 'Hello, my name is <a href="https://stackoverflow.com/foo/bar">foobar</a> My favorite food is <a href="https://google.com/food/pizza">pizza</a ...

Validating forms in React with Material-UI using hooks

Currently, I am working on a Next.js project that utilizes Material-UI as the primary UI framework. For validation purposes, I am implementing a React hooks form. Within my main component, I have the form structure with separate child components for vari ...

execute a method encapsulated within a factory from external to AngularJS

Although this question is similar to others posted here, none of the solutions provided have worked for me. My Cordova/AngularJS/Ionic app currently polls a remote server every 10 minutes to retrieve JSON data, and push notifications are working correctly ...

Ways to make JavaScript cycle through a set of images

I'm having trouble trying to set up a code that will rotate multiple images in a cycle for an image gallery I'm working on. So far, I've only been able to get one image to cycle through successfully. Any help or suggestions would be greatly ...

Retrieve the data stored in a selection of checkbox fields on a form

I have a table of checkboxes: <div> <h1 class="text-center">Select activities</h1> <div class="row"> <div class="col"></div> <div class="col-md-8 col-lg-8"> <h3>Link activ ...