Having trouble with the page layout in AngularJS

I am currently delving into Angular JS in order to fulfill some academic requirements. The issue I am facing is with the rendering of a landing page after successfully logging in through a login portal that caters to three types of users. Strange enough, when I embed the code for this landing page directly into "index.html," everything works flawlessly. However, when I attempt to load it inside the ui-view using state transitions, certain functionalities like the submenus (nested li tags within ul tags) do not seem to work as expected. I am utilizing "state" for navigating between different sections, but no errors are being reported, leaving me clueless as to where the problem lies. I believe I have included all relevant snippets of code, but if necessary, I can certainly provide the entire code base.

Any assistance would be greatly appreciated.

app.js

'use strict';

angular.module('Authentication', []);

//angular.module('Home', []);

angular.module('Registration', []);

angular.module('Dental', ['ui.router','Authentication','Registration'])
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){

       $stateProvider
        // State - User Login
            .state('login', {
            url: "/login",
            templateUrl: "app/authentication/views/login.html",
            controller: "AuthenticationController"
        })

        // State - Admin Landing Page
        .state('admin', {
        //abstract: true,
        url: "/admin",
        templateUrl: "app/admin/home/views/admin_main.html",
        controller: "RegistrationController"
      })

      // State - Admin Sub Pages - Registration Page
      .state('register', {
        parent: 'admin',
        url:'/register',
        views: {
          'admin@admin' : {
              templateUrl: "app/admin/settings/views/clinicDetail.html",
          }
        },
        controller: "RegistrationController"
      })

      // State - Admin Sub Pages - Personal Details Page
      .state('register.personal', {
        parent: 'register',
        url:'/personal-details',
        views : {
          'registration' : {
            templateUrl : 'app/admin/registration/views/personalDetails.html'
          }
        }
      })
}])

admin_main.html

<div class="left-navigation">
            <ul class="list-accordion">
                <li><a href="#" class="waves-effect"><span class="nav-icon"><i class="fa fa-home"></i></span>
                <span class="nav-label">Home</span> </a>

                </li>
                   <li><a class="waves-effect"><span class="nav-icon"><i class="fa fa-align-justify"></i></span><span class="nav-label">Registration</span></a>
                    <ul>
                        <li><a ui-sref="register">Add New Patient</a>
                        </li>
                        <li><a href="#">Show Patients</a>
                        </li>
                    </ul>
                </li>
                <li><a href="#"><span class="nav-icon"><i class="fa fa-table"></i></span><span class="nav-label">Appointment</span></a>
                    <ul>
                        <li><a href="#">Fix Appointment</a>
                        </li>
                        <li><a href="#">View Appointment</a>
                        </li>
                        <li><a href="#">Day Sheet</a>
                        </li>
                        <!--<li><a href="stack-tables.html">Stack Tables</a> -->
                        </li>
                    </ul>
                </li>
                <li><a href="#"><span class="nav-icon"><i class="ico-hammer-wrench"></i></span><span class="nav-label">Employee Registration</span></a>
                    <ul>
                        <li><a href="#">Employee Category</a>
                        </li>
                        <li><a href="#">Add New Employee</a>
                        </li>
                        <li><a href="#">View Employees</a>
                        </li>
                        <li><a href="#">Reports</a>
                            <ul>
                                <li><a href="#">Employee Details</a>
                                </li>
                            </ul>
                        </li>
                        <!--<li><a href="#">Bootstrap Elements</a>
                        </li> -->
                    </ul>
                </li>
               </ul>
               </div>

Answer №1

To organize your ui-view, you can create a separate div and save it in a new html file named 'home.html' or any other preferred name.

Here is the content of home.html:

<div class="jumbotron">
<div class="container">
  <div class="col-xs-offset-2 col-xs-8">
    <h3> Clinic Management System </h3>
    <a ui-sref="login"> <button class="btn btn-success">Start</button></a>
  </div>
</div>

Inside the body tag:

<body>
   <div ui-view>
</div>

Then include a new state in your stateProvider with a default state set to '/home':

$urlRouterProvider.otherwise('/home');

$stateProvider.state('home', {
  url: "/home",
  templateUrl: "app/home/views/home.html",
  controller: "HomeController"
})

I hope this explanation helps.

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

Next.js is able to generate a unique URL that strictly handles code execution without any visual elements

Currently, I am in the process of developing a new website using NextJS. One issue that has come up involves a password reset verification endpoint. After a user initiates a password reset, it is sent to the API for processing and then redirected back to ...

Text that changes within a set-sized box

I'm working with a fixed-size div that contains dynamically generated text. Is there an easy method using DOJO or plain Javascript to truncate the text before the end of the div and add "..."? How can I accomplish this regardless of the font size bein ...

Transitioning from Jquery to vanilla JavaScript or transforming Jquery code into pseudo code

Struggling with a snippet of jQuery code here. While I have a good grasp on JavaScript, my knowledge of jQuery is somewhat limited. I am seeking assistance to analyze the following code in order to translate it into plain JavaScript or pseudo code that ca ...

Is there a more efficient method to halt a jQuery animation plugin? Surely, there must be a more effective solution

After feeling under the weather for the past week and feeling incredibly bored, I decided to delve into the world of creating jQuery plugins. In just half an hour, I managed to put together a plugin that mimics the "wiggle" effect when pressing and holding ...

Creating users or custom roles in MongoDB on a NodeJS server is not currently possible

I have been attempting to directly create users on my database through our Express server, utilizing MongoDB 3.4 for the backend. Below is the current code snippet from the server: const express = require('express'); const bodyParser = require(& ...

Looking for a JavaScript (Angular) event listener to trigger when closing pages and tabs

I am looking for an event that will only work when closing a page or tab, but should not be triggered when the page is refreshed. I am aware of the "beforeunload" event, but it also gets activated on page refresh. Below is the code snippet I am currently ...

Leveraging Javascript to generate universal HTML content for various Javascript files

Present Situation: I have a timesheet feature that enables users to input their leave, TOIL, and sick days along with the respective hours. Additionally, there is a table that dynamically adds a new row every time the plus button is clicked using the foll ...

Issue-free AJAX call to Neo4j database on local server with no 'Access-Control-Allow-Origin' problem

I'm currently working on a basic JavaScript AJAX request to connect from a MAMP server running at localhost:8888 to a Neo4j database running on localhost:7474. The issue I'm encountering is the following error message: XMLHttpRequest cannot l ...

Messages using JQuery input technology

My form includes two inputs. The first input must be completed before moving on to the second. If the user selects the second input before the first, they will receive a message instructing them to fill out the initial input. I now want to ensure that aft ...

When you hover over the button, it seamlessly transitions to a

Previously, my button component was styled like this and it functioned properly: <Button component={Link} to={link} style={{ background: '#6c74cc', borderRadius: 3, border: 0, color: 'white', height: 48, padding: '0 ...

"Clicking on the hamburger menu causes the webpage to reset its scroll

I recently integrated a mobile hamburger menu into my website, which is primarily built around a single page. However, I noticed that whenever I open the menu, it automatically scrolls to the top of the page regardless of where you were previously scrollin ...

Tips for Updating Information within a Table with the Help of jQuery, AJAX, PHP, and MySQL

I need some assistance! Here's the scenario: There are two tables containing data from the database. The number of tables varies based on the user posting them. I utilized a "while loop" to display the table with data on the page. Now, I want the d ...

What is the best way to extract user input from a web form and utilize it to perform a calculation using jQuery?

Is it possible to retrieve user input from a web form and use it to perform calculations with jquery? I am interested in extracting a numerical value entered by a user in a web form. Upon clicking "NEXT", I intend to multiply this number by a predefined c ...

The $scope variable does not sync with the express API

I have noticed that the static part of my app is loading fine. Recently, I integrated a service using Express as a simple API. However, when I attempt to set the #scope from my module's controller, it seems like it hasn't loaded at all. I am puzz ...

Can HTML tags be used within directive attributes in AngularJS?

During a code review, I came across a custom directive with HTML tags inside an attribute: <form-field help="Use <b>foo</b> option to blah blah"></form-field> Initially, I found this approach quite unusual and assumed it might cau ...

Generating an associative array in PHP using AJAX with JQUERY

Seeking assistance for the first time here. I'm struggling to find a suitable title, but it's all I can think of at the moment. I've been working on this for 2 days now and have read so many things that I feel completely lost. I'll try ...

If the mouse hovers over again, implement this action using jQuery

Check out my code snippet here: http://jsfiddle.net/sZKeM/1/ I have created a functionality where a box is displayed when hovering over a button and hidden when the mouse leaves the box. However, I am looking to tweak it so that the box hides when hoverin ...

Having trouble customizing the Material UI button in React?

For a recent project, I utilized the older version (v1) of Material UI to ensure compatibility with Node 10.8. In order to implement a round button, I referred to this demo. The round mini button functioned perfectly without any applied themes. <Button ...

"Ajax validation is causing the duplication of the HTML page content within an HTML

My PHP username validation with Ajax code seems to be duplicating my HTML page inside an HTML div element, which is used for displaying Ajax errors. Despite trying various solutions and searching on Google, I have not been able to find a resolution yet. Th ...

Enclosing $( ) around a String will result in an empty output

I am attempting to remove HTML tags from a string using the method outlined in this particular post. The string I am looking to strip the tags from is a JSON property called item.content. Therefore, my code appears as follows: $(item.content).text(); Whe ...