Only one UI-Sref link is functional, while the remaining links are not

I have a situation where I have three links on an Angular template. The first link is working fine, but the other two are not. The first link displays the cursor as a pointer, while the second and third links display the cursor as auto/default. Here are the links:

<a ui-sref="doctorMain">Doctor Main</a><p/>
<a ui-sref="doctor.chat">Doctor Chat</a><p/>
<a ui-sref="user.chat">User Chat</a> 

The first link is working fine, but when clicking on the other two, I get the following error message in the console:

Error: Could not resolve 'user.chat' from state 'userMain'
    at Object.transitionTo (angular-ui-router.js:3074)
    at Object.go (angular-ui-router.js:3007)
    at angular-ui-router.js:4057
    at angular.js:17918
    at e (angular.js:5552)
    at angular.js:5829(anonymous function) @ angular.js:12520(anonymous function) @ angular.js:9292(anonymous function) @ angular.js:17921e @ angular.js:5552(anonymous function) @ angular.js:5829

This is how I have set up routing in my app.config module.

$stateProvider
        .state('doctorMain', {
            url: "/doctorMain",
            templateUrl: "partials/doctor/doctor-main.html",
            controller: 'DoctorJoinChat',
            data: {
                doctor: true
            }
        })
        .state('doctor.chat', {
            url: "/doctorChat",
            templateUrl: "/partials/test.html",
            controller: 'DoctorJoinChat',
            data: {
                doctor: true
            }
        })
        .state('userMain', {
            url: "/userMain",
            templateUrl: "/partials/patient/form.html",
            data: {
                user: true
            }
        })
        .state('user.chat', {
            url: "/userChat",
            templateUrl: "/partials/test.html",
            data: {
                user: true
            }
        });

Answer №1

To enhance clarity, it is recommended that you label your primary roots as 'doctor' rather than 'doctorMain' and 'user' instead of 'userMain' (with child roots using the main root's name as a prefix). Is this explanation clear to you?

Answer №2

When you use the syntax user.chat, you are creating a new child state called chat within a parent state named user. This is indicated by the dot convention - parentState.childState.

In order for doctor.chat and user.chat to be valid, there must be parent states named doctor and user. To make this work, you need to change the names of your main states as shown below.

  • doctorMain should be renamed to doctor
  • userMain should be renamed to user

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

Encountering the "Component resolution failed" error in Vue 3 when using global components

When I declare my Vue components in the top level HTML file, everything works fine. Here is an example: <body> <div class='app' id='app'> <header-bar id='headerBar'></header-bar> ...

Is it feasible to display two slides simultaneously in the carousel?

I have recently delved into learning about Angular.js and am currently utilizing the Carousel control in Angular-ui. I am curious to know if it is feasible to showcase two slides simultaneously instead of just one? My intention is to present the images in ...

Traversing data in SQL Server that has been transmitted from Angular AJAX requests

Here is a snippet of the sample data being sent: { "Demo":"A 25-54", "Headlines": { "0":"Headline one", "1":"Headline two" } } This is how the post request is structured: $http({ method : 'POST', url : &a ...

What is the best way to update an array within an object using Redux?

I am currently working on a code for redux that involves an array. const initialState = [{ id: '1', title: '', description: '' }]; My goal is to update the array to contain two objects like this: [{ id: '1', title: ...

The issue with the Sails.js application is that it fails to update files from assets after

Currently, I am working on a Sails.JS application with Angular.JS as its front-end framework. All the angular files are stored in /assets/linker and they are correctly injected upon start. However, I have encountered an issue where any changes made to the ...

Another option instead of using ng-repeat when scope is not required

Currently, I am facing a problem where Angular is generating a large number of rows and columns, resulting in poor performance! I suspect that the issue lies with ng-repeat creating a new scope for each element it generates. However, since my function doe ...

Navigating child HTTP requests for a collection in AngularJS

Within my service.ts file, I am reading a bookmarks.json file that contains a list of bookmarks. For each bookmark, I need to set a favicon by making a call to https://www.google.com/s2/favicons?domain=... Below is the function responsible for this tas ...

Having trouble extracting a JSON object from a POST request in Express v4 with the help of body-parser?

Currently, I am delving into the world of server-side code and learning about Node.js and Express. However, I am facing some challenges when it comes to receiving and parsing a JSON object sent from a POST request. Despite checking various resources (linke ...

The MetaMaskOnboarding variable is causing a disruption in my code

I have been following the MetaMask basic dapp tutorial. Everything was going smoothly until I came across the MetaMaskOnboarding section which triggers when the browser detects that Metamask is not installed. const onboarding = new MetaMaskOnboarding({ f ...

Is it possible to convert the text.json file into a jQuery animation?

Looking to extract information from text.json and integrate it with my jquery.animation(). My goal is similar to the one demonstrated here. Instead of using "data" attributes like in that example, I want to parse the text based on the "ID" property as a k ...

Executing Sequential Jquery Functions in ASP.Net

I have successfully implemented two JQuery functions for Gridview in ASP.Net 1. Enhancing Gridview Header and Enabling Auto Scrollbars <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script& ...

Utilize only certain JSON properties within JavaScript

I have access to an array of JSON objects. [ { Id: "1", StartNo: "1", ChipNo: "0", CategoryId: "0", Wave: "0", Club: "", FirstName: "Lotta", LastName: "Svenström", FullName: "Lotta Svenström", ZipCode: "24231" }, {...} ] My goal is to create a new data ...

Why are the HTML links generated by JS not opening in Chrome?

<a href='http://www.xyz.hu/xyz' alt='Kosár' title='Kosár'>Megtekintés</a> Additionally: - A setInterval function refreshes the sibling's content every second, although it should not affect this specific el ...

Tips for maintaining the size of an object while resizing a window

My circles are designed to increase in width at regular intervals, and once they reach a certain scale, they disappear and start over. However, every time I resize the screen or zoom in and out, the circle gets distorted into an oval or stretched object. H ...

The issue arises due to conflicting indent configurations between eslint and @typescript-eslint/indent

Currently, I am using eslint and prettier in a TS express application. I am trying to set the tab width to 4, but it appears that there is a conflict between the base eslint configuration and the typescript eslint. When looking at the same line, this is w ...

Using React-router-dom's Link component can cause styling inconsistencies with material-ui's AppBar Button

Exploring the use of a material-ui Button with react-router-dom's Link is showcased here: import { Link } from 'react-router-dom' import Button from '@material-ui/core/Button'; <Button component={Link} to="/open-collective"> ...

How can I dynamically assign a className in a React component based on the current state when importing styles?

I've been utilizing the style-loader to insert CSS modularly into my components ({style.exampleClassName}). My goal is to showcase a loader for a specific duration before displaying an image (at least 16 of these components in a grid layout). This i ...

Sharing a session with a Django template using jQuery

I am attempting to use $.load() to load a Django template that contains {% if user.is_authenticated %}. However, when the template is rendered on the server in response to an AJAX-generated HTTP request, the user object is undefined. Here is my_template.h ...

Is there a way to reset an AngularJS controller to its initial state after a data change?

I have been trying to understand the API documentation for this, but it seems a bit challenging. Let's say I have a controller that retrieves data on its initial call: myCtrl = function ($scope, Data) { $scope.data = []; data_promise = Data.getD ...

Relationship between multiple Mongoose instances linking to a single entity

Having an issue regarding mongoose and relationships. My "Athletes" collection has the following schema: var athletesSchema = mongoose.Schema({ name : String, regionName : String, age : Number, overallScore : Number, scores : { ordinnal : String, ...