I am facing an issue with the Angular signup page that is using ui-router, as it is unable

I have been working on an Angular sign-up page and here is the project directory structure:

    signUpPage-Angular
    bin
    bower_components
    model
      mongodbApp.js
    node_modules
    **partials
        fail.html
        main.html
        success.html**
    public
    images
    **javascripts
        signUp.js**
    stylesheets
    routes
      index.js
      users.js
    **views
        index.ejs**
    app.js
    package.json

All HTML files can be found in the partials folder.
The JavaScript controller code resides in the signup.js file.
The main HTML content is contained in views/index.ejs.

I have encountered an issue with accessing the HTML using ui-router where the code seems to not function correctly. I am unsure if this is due to an error in the path or if there is a problem with the ui-router code itself.

The router is failing to navigate to the designated page:

Upon running the code, the address bar displays: http://localhost:3000/#/partials/main.html, but the main page content is not being displayed. Additionally, no errors are being reported.

index.ejs

<!DOCTYPE html>
<html ng-app="myApp">
  <head>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
      <link rel='stylesheet' href='/stylesheets/style.css' />
      <script src="/angular/angular.js"></script>
      <script src="/ui-router/release/angular-ui-router.min.js"></script>
      <script src="/javascripts/signUp.js"></script>
  </head>
  <body ng-controller="myCtrl">
   <div ui-view></div>

  </body>
</html>

signUp.js

angular.module("myApp",['ui.router'])
.config(function($stateProvider, $urlRouterProvider){
    $urlRouterProvider.otherwise('partials/main.html');
    $stateProvider
        .state('success', {
            url: "/success",
            templateUrl:'partials/success.html'
        })
        .state('fail', {
            url: '/fail',
            templateUrl:'partials/fail.html'
        })

})
    .controller("myCtrl", function($scope, SignUp,$state){

        $scope.clearPerson = function(){
        $scope.first = "";
        $scope.last = "";
        $scope.email = "";
        $scope.password = "";
        $scope.confirm = "";
        $scope.dob = "";
        }



        $scope.addPerson = function(){
           /* console.log($scope.first);
            console.log($scope.last);
            console.log($scope.email);
            console.log($scope.password);
            console.log($scope.confirm);
            console.log($scope.dob);*/
            $scope.person = {
                firstName: $scope.first,
                lastName: $scope.last,
                email: $scope.email,
                password:$scope.password,
                dateOfBirth: $scope.dob
            }

            console.log($scope.person);
            SignUp.add($scope.person).success(function(res){
                $state.go("success");
                console.log(res);
            }).error(function(res){
                $state.go("fail");
                console.log("error");
            })

        }

    })
   .factory("SignUp", function($http){
        return{
               add: function(person){
                return $http.post('/signup',person);
            }
        }
    })

main.html

    <h1>Sign up Page</h1>
<div class="new-container">
    <div class="container">
        <h3>Create an ID</h3>

        <form class="form-horizontal" name="signup" novalidate ng-submit="addPerson()">
            <div class="form-group">
                <h4>Name</h4>
                <label  class="col-sm-2 label-control align-text" >First Name</label>
                <div class="col-sm-4 text-margin" >
                    <input name="first"  ng-maxlength=50 ng-model="first" type="text" class="form-control"  required>
                    <div class="error"
                         ng-show="signup.first.$dirty && signup.first.$invalid">
                        <small class="error"
                               ng-show="signup.first.$error.required">
                            Your name is required.
                        </small>
                        <small class="error"
                               ng-show="signup.first.$error.maxlength">
                            Your name cannot be longer than 50 characters
                        </small>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 label-control align-text" >Last Name</label>
                <div class="col-sm-4 text-margin">
                    <input name="last"  ng-maxlength=50 ng-model="last" type="text" class="form-control"  placeholder="optional">
                    <div class="error"
                         ng-show="signup.last.$dirty && signup.last.$invalid">
                        <small class="error"
                               ng-show="signup.last.$error.maxlength">
                            Your name cannot be longer than 50 characters
                        </small>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <h4>ID and Password</h4>
                <label class="col-sm-2 align-text label-control">Username</label>
                <div class="col-sm-4 text-margin">
                    <input name="email" ng-maxlength=56 ng-model="email" type="email" class="form-control" placeholder="Email" required>
                    <div class="error"
                         ng-show="signup.email.$dirty && signup.email.$invalid">
                        <small class="error"
                               ng-show="signup.email.$error.required">
                            Your email is required.
                        </small>
                        <small class="error"
                               ng-show="signup.email.$error.maxlength">
                            Your name cannot be longer than 56 characters
                        </small>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 label-control align-text">Password</label>
                <div class="col-sm-4 text-margin">
                    <input name="password" ng-minlength=6 ng-model="password" type="password" class="form-control al" placeholder="Password" required>
                    <div class="error"
                         ng-show="signup.password.$dirty && signup.password.$invalid">
                        <small class="error"
                               ng-show="signup.password.$error.required">
                            Your password is required.
                        </small>
                        <small class="error"
                               ng-show="signup.password.$error.minlength">
                            Your name cannot be atleast 6 characters long.
                        </small>
                    </div>

                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 label-control align-text">Confirm Password</label>
                <div class="col-sm-4 text-margin">
                    <input name="confirm" compare-to="password" ng-model="confirm" type="password" class="form-control"  placeholder="Password" required>
                    <div class="error"
                         ng-show="signup.confirm.$dirty && signup.confirm.$invalid">
                        <small class="error"
                               ng-show="signup.confirm.$error.required">
                            Password confirmation is required.
                        </small>
                        <small class="error"
                               ng-show="signup.confirm.$error.errorCompareTo">
                            Your passwords do not match.
                        </small>
                    </div>

                </div>
            </div>
            <div class="form-group">
                <h4>Date of Birth</h4>
                <label  class="col-sm-2 label-control align-text">Birthday</label>
                <div class="col-sm-4 text-margin">
                    <input ng-model="dob" type="date" class="form-control"  placeholder="MM/DD/YYYY" required>
                </div>
            </div>
            <div class="form-group" >
                <div class="col-sm-offset-2 col-sm-10 float-right" >
                    <button type="submit" class="btn signUp" >Sign Up</button>
                    <button type="submit" class="btn btn-default" ng-click="clearPerson()">Clear</button>
                </div>
            </div>
        </form>
    </div>
</div>

fail.html

<h1>fail</h1>

success.html

<h1>success</h1>

Answer №1

To implement this:
 $urlRouterProvider.otherwise('/');

Within the State section:
     $stateProvider
        .state('main', {
                url: "/",
                templateUrl:'partials/main.html'
        })

By following these steps, you will be able to access the signUpPage easily.

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

Creating effective test cases for Angular JS controllers

Our team has recently taken on the task of writing test cases for our application, specifically focusing on controllers. Utilizing Mocha, Chai, and Sinon libraries, we are looking for guidance on how to effectively write these test cases. We have shared a ...

Upon completion of an Ajax call, ReactJS will execute a callback function

I'm relatively new to React and encountering an issue. I am fetching data from an API that requires a callback function as a parameter (&callback=cb). I've chosen to use the fetchJsonp library for making cross-domain fetch requests. Despite pass ...

Encountering a 404 error while making a jsonp call in Angular

I am currently working on a project running on localhost with a MySQL database. My goal is to display data from this database on a web page using a Server.js file that utilizes Express and NodeJS. var express = require("express"); var mysq ...

tips for generating a random number for direct display

Can anyone help me figure out how to automatically display the total of numbers from this script on my blog post without having to click anything? Additionally, I need it to update if the browser is refreshed. ` http://jsfiddle.net/BenedictLewis/xmPgR/ ...

What could be causing the images' load event not to work as expected?

I'm attempting to implement a load event for my images using native JavaScript. Below is the code snippet I am currently using: var imgs = $("figure img"); // querySelectorAll for(var i = 0, l = imgs.length ; i < l ; ++i) imgs[i].addEventListen ...

Angular/Ionic - How can I prevent my function from being called repeatedly while typing in an input field?

I am currently in the process of self-teaching how to construct an Angular/Ionic application. To store JSON, I am utilizing Backand and aiming to retrieve a random JSON value each time the page is refreshed. An issue I am facing is that the random call fu ...

Challenges with Asset Management in Vite Compilation Result

I'm encountering a problem with structuring assets in the output directory while utilizing Vite for my project. I have set up the output.assetFileNames option to categorize assets into subfolders based on their types (css, fonts, img, js), but it&apos ...

Tips for displaying a child React component for a specific duration

One of the React components I have is called PopUpBanner, which is utilized to display messages. For instance, in my login component, I employ it in this manner. If an error arises, the bannerMessage state is updated to showcase the message on the banner: ...

Looking to crop a canvas without changing its dimensions using jQuery

I'm currently working on a project that involves overlaying two images; one uploaded by the user and the other a default image. However, I am facing an issue when the uploaded image is a rectangle instead of a square, causing the canvas to resize it. ...

Guide on selecting and initializing functions in AngularJS upon page load

When using AngularJS, how can I ensure that the "All Categories" button is highlighted and initialized on page load or refresh? This could possibly be achieved by utilizing ng-init or ng-options. Controller $scope.selectCategory = function(newCategory) { ...

Discovering the number of words, extracting specific words, and transferring them to a URL using JavaScript

I have retrieved a document from a URL and saved the response. There are 3 tasks I need to accomplish here:- Calculate the word count in the document. Gather information for the top 3 words (sorted by frequency) including synonyms and parts of speech. A ...

Download a complete website using PHP or HTML and save it for offline access

Is there a way to create a website with a textbox and save button, where entering a link saves the entire website like the 'save page' feature in Google Chrome? Can this be done using PHP or HTML? And is it possible to zip the site before downloa ...

Automatic execution of expressions in browserify upon initialization

Utilizing browserify alongside node.js allows me to utilize require() in my JavaScript files. Within my game.js file, I have the following code: var game = new Phaser.Game(800, 600, Phaser.AUTO, 'snakeGame'); var menuState = require('./me ...

Having trouble executing the yarn command for clasp login

Issue with running yarn clasp login I am not very proficient in English, so please bear with me. 8> yarn clasp login yarn run v1.22.22 $ C:\Users\myname\Desktop\個人開発プロジェクト\clasp-240418\node_modu ...

Adjusting the background element of a fullpage.js layout during resizing and customization

Is there a way to make the background image responsive on a fullpage.js page, specifically for mobile and tablet devices? How can I ensure that a specific part of the image stays at the center of the page when resizing? For instance, in the provided imag ...

Learn how to mock $resource in AngularJS using $promise.then in your jasmine tests

I have a factory that utilizes Angular resource to fetch data from an API. I've developed a function called getObjectById within the service, which uses the factory to request a specific object by ID, then adjusts the object before returning it. Serv ...

Issues with Contenteditable functionality in JavaScript

My goal is to make a row editable when a button is clicked. $(":button").click(function(){ var tdvar=$(this).parent('tr').find('td'); $.each(tdvar,function(){ $(this).prop('contenteditable',true); }); }); <s ...

Modify the placeholder color for a disabled Input element to match the overall Mui theme design

I am struggling to change the color of the placeholder text in a disabled input field within my app's theme. Despite attempting to target the MuiFormControl, MuiInputBase, and MuiInput components in my theme.tsx file on CodeSandbox, I have not been su ...

Struggling to get Ajax to function on IE8 with dropdowns, while other browsers are working perfectly fine

My AJAX code functions properly in most browsers, however, it is not performing well in IE. While it successfully creates an XMLHTTPRequest object, the data retrieved from my PHP script is only returning an empty list! Check out my JavaScript code: < ...

Comparing Angular extend to $provide.decorator: A breakdown

I find myself in a state of confusion. Can you please provide some clarity on the distinction between angular.extend() and $provide.decorator? When and why would one use the latter option? Does decorator serve a different purpose compared to extend? Desp ...