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

What methods are available for identifying non-operational pointer-events?

According to this resource, Opera 12 does not support pointer-events, causing issues with my website. Interestingly, they do support the property in CSS but don't seem to implement it correctly. Modernizr's feature detection doesn't help in ...

Understanding how to retrieve the value count by comparing strings in JavaScript

In my array object, I am comparing each string and incrementing the value if one letter does not match. If three characters match with the string, then I increase the count value; otherwise, it remains 0. var obj = ["race", "sack", &qu ...

Experiment with AngularJS and Jasmine by utilizing the stand-alone command line interface for testing

I have been working on a basic .js file and testing it with Jasmine. The tests run smoothly when using Jasmine's SpecRunner.html. However, I was wondering if it is possible to achieve the same results through a command line interface. I do have node ...

Scale transformation - I am aiming for it to exceed the limits, yet it remains contained within

Currently, I am working on enhancing my carousel by implementing a zoom effect when hovering over the images. However, I have encountered an issue where the image gets hidden within the div container and doesn't overflow as expected. I tried adjusting ...

Transmitting special symbols through Socket.io

I've been working on a small project based on Socketio 0.9 and everything is running smoothly, except for a minor problem with special characters. In the web client, I am creating a dynamic JSON object using JavaScript that is then emitted to the ser ...

Is it possible to retract a message on Discord after it has been sent?

I have a code that automatically sends a welcome message when a new member joins the guild, and I want it to be deleted shortly afterwards. Here is my current code: client.on('guildMemberAdd', (member) => { var server = member.guild.id; i ...

Do not allow nested objects to be returned

I am facing an issue with typeorm, where I have a queryBuilder set up like this: const projects = await this.conn.getRepository(UserProjectRelations).createQueryBuilder("userProject") .innerJoin("userProject.userId", ...

Issue with Lao font not displaying correctly on Ionic for Android version 4.3

My application requires the use of two languages, specifically Lao and English, and I am utilizing i18n for localization purposes. To customize the font family style for the Lao language, I have implemented the following code: @font-face { font-family: & ...

Merge the variables extracted from an array of objects

I need to extract specific data from an array of objects and perform a calculation. For example, the provided data is as follows: const item = [{ "act": "Q", "line": 1, &quo ...

Performing subtraction operation on a selected floating-point value from a database using PHP

I am facing an issue with my code where I need to subtract a float value selected from the database and update the subtracted values in the database table. Below is my code snippet: $AmountGiven = $_POST['AmountGiven']; $conn = mysqli_connect("l ...

The parameters passed in an axios get request are not carried over to a create request

Exploring the capabilities of the YouTube API with ReactJS While working with the YouTube API, I came across the create method in axios. However, I faced an issue where the params were getting overwritten. What am I missing here? I have a file named yout ...

Mapping dynamic objects inside a repeat loop in AngularJS ui-select

Here is my ui-select directive code that is working perfectly fine. Within a repeat loop, I need to dynamically set the property of the CODE object (which is ID) to something like code[fwValueProperty]. Since it is not using ng-repeat, I cannot use it in ...

I'm looking to automate a system response whenever a user inputs something - how can I achieve this using NodeJS and Socket

I'm looking to create a feature where, if a user enters a specific command, the socket.io will respond with a predefined message. For example: Input: !hi Output: hello! If anyone knows how to achieve this, I'd appreciate some guidance, tha ...

Retrieve the latest information and update the database with just one ajax request

I am attempting to update a row in the database and retrieve the updated row one at a time using an AJAX call. JavaScript inside the ready function $("button[name='teacher_lock_exam']").on(ace.click_event, function () { var current_exams_id ...

What is the best way to split an array into four columns and allocate 10 <li> items from the array to each column?

If I have a dynamic array with 40 elements that changes on every render, how can I loop through the array and return 4 groups of elements, each containing 10 items without any repetition? I want to style these objects in the array using a parent flex con ...

Is it possible to incorporate an external javascript file in my CSS file?

Currently, I am attempting to create a setup where my background adjusts based on the width of the user's browser. However, I am constrained by a background specified in the external stylesheet under a specific element. While I have the ability to alt ...

Utilizing Loops to Generate Unique CSS Designs on an HTML Page

View reference image ->Take a look at the reference image provided. ->In the image, a for loop is used to create box designs and displayed above. ->The goal is to change the background color and border color of all boxes using a single HTML cla ...

The tablesorter plugin from Jquery isn't functioning properly on my dynamically loaded ajax table

I am having trouble getting Tablesorter to work with my table. I attempted to use .trigger('update') but it did not have the desired effect for me. Instead, I tried using stupidtable and it worked to some extent, but not perfectly (it did not sor ...

Ways to create a table with columns from various fields obtained through an API call

Looking to preprocess data received from an API, the raw data is structured as follows: Desiring to dynamically generate a table with columns based on the fields task_name and saved_answers. It's important to note that saved_answers might contain var ...

Discover the art of utilizing two distinct binding strings, wherein upon the selection of either, the alternate binding string shall automatically be

Having to use two different bindingstrings is a requirement due to a tool used for creating PDFs. My objective is to have the corresponding bindingstring turn "Off" when a user clicks on either the Yes or No button, and have the clicked button turn to "Yes ...