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

The image file that was uploaded to our S3 storage has been detected

I'm attempting to upload an image created by cropperjs to a DigitalOcean space. To achieve this, I am utilizing a pre-signed URL and performing a put request using Axios. The problem arises when I try to open the uploaded image, as it appears to be ...

What steps should be taken to develop a Hybrid Mobile App concept?

We are currently developing our first hybrid mobile application with a monetizable idea in mind. After conducting some research, it seems that to reach our end goal we will need: A Front End UI Framework: options include Ionic or AngularGap (although d ...

Display an AJAX div when the image is hovered over and have it track the movement of

I am seeking assistance with my website project, which involves providing users with download links to movies. However, I am struggling to make the preview_block div(id) appear when the mouse hovers over the movie_block div(id). Additionally, I am having ...

Getting the value of a session variable in JavaScript from a PHP file

Despite the numerous inquiries on this topic, I am still struggling to comprehend it. Scenario: An image with a hyperlink When the image is clicked: Verify if session exists If session exists, open the link If session does not exist, display the login ...

Avoid navigating through hidden tab indexes

Below is the HTML code that I am working with: <span tabindex="19"> </span> <span tabindex="20"> </span> <span tabindex="21"> </span> <span id="hidden" tabindex="22"> </span> <span tabindex="23"&g ...

Tips for validating and retrieving data from a radio button paired with an input box in reactjs

I'm diving into the world of React and facing a challenge with multiple radio buttons that have associated input fields, like in this image: https://i.stack.imgur.com/Upy3T.png Here's what I need: If a user checks a radio button with a ...

What sets these async method declarations apart?

What goes on behind the scenes? const facade = { // A: doSomething: async () => await delegatedFunction(), // B: doSomething: async () => delegatedFunction(), // C: doSomething: () => delegatedFunction(), // D: do ...

I'm struggling to grasp the concept of State in React.js

Even though I'm trying my best, I am encountering an issue with obtaining JSON from an API. The following error is being thrown: TypeError: Cannot read property 'setState' of undefined(…) const Main = React.createClass({ getInitia ...

How can I create a semantic-ui dropdown with a dynamically generated header?

Here are the dropdown options: const options = [ { key: '1', text: 'Example 1', value: 'Example 1', type:'ABC' }, { key: '2', text: 'Example 2', value: 'Example 2', t ...

Trouble transferring $rootScope.currentUser between AngularJS profile and settings page

I am in the process of setting up a site using Angular, Express, Node, and Passport. Currently, I am configuring Angular to monitor the $rootScope.currentUser variable with the following code: app.run(function ($rootScope, $location, Auth) { // Watch ...

What is the best way to get rid of a connect-flash notification?

I'm having trouble removing the message (with the username displayed) after logging out by pressing the logout button. Every time I try to press the logout button, it just refreshes the page without any action. I want to stay on the same page and not ...

Tips for extracting and utilizing a JSON object provided by the parent page:

Sorry in advance if this question has already been addressed. I've spent hours searching on Google, but haven't found a satisfactory answer yet. Below is the code snippet I'm working with: <ion-content> <div class="list"> ...

Updating data from an API within a div using AJAX calls in a React application

I have designed a React template to showcase live football scores in the following manner: const LiveScore = () => { const {direction} = useThemeProvider(); const [selectedDay, setSelectedDay] = useState(parseInt(dayjs().format('DD'))); retur ...

Creating various containers in React JS for different components

I am faced with the task of rendering multiple DOM elements from my JavaScript code. Imagine I have div elements like this: <div id="div1"><div> //Some Html tags <div id="div2"><div> //Some Html tags <div id="div3" ...

Fetching data using JSONRequest sample code

I am new to web development and this is my first attempt at using JSON. On the JSON website (http://www.json.org/JSONRequest.html), they recommend using JSONRequest.get for certain tasks. However, I keep running into an error stating "JSONRequest is not ...

Access in-depth data by clicking on a map to get detailed information

Recently, I took on the challenge of managing a golf club website after the original creator had to step away. One urgent issue I need to address is fixing a malfunctioning flash animation that provides information about each hole on the course. My plan is ...

What is the best way to set the default display of the first option value in a dynamically populated <select> dropdown menu?

I have a field that displays options dynamically. I am looking to set the first option value as the default in the select field. Can someone provide assistance with this? <div class="col-lg-4"> <select name="trader" class="form-control" id="sele ...

Adding a tooltip with a date format to a Highchart graph

Hey everyone, I'm currently working with a Highchart and I want to customize the tooltip value in a specific format. My categories and series are structured as follows: {"Categories":["2015-11-09","2015-11-08""2015-11-15"],"Series":[2,0,2]} Current ...

My div is currently being concealed by a jQuery script that is hiding all of its

Below is the current code snippet: jQuery(document).ready(function($) { $("ul.accordion-section-content li[id*='layers-builder'] button.add-new-widget").click(function() { $("#available-widgets-list div:not([id*='layers-widget']) ...

Exploring the wonders of Ajax with KnockoutJS Mapping

I have been assigned the task of conducting a POC of KnockoutJS, but I am facing an issue that seems to be difficult to solve. My goal is to fetch data from a service using Ajax and then populate a form with ko.mapping.fromJS(). However, the form does not ...