Retrieve the state of a child component from within the child component

I am encountering an issue while trying to access a child state from another child state. The error message I receive is:

angular.js:14195 Error: Could not resolve '#/projects/detailProject' from state 'projects.list

Here are the states defined in the application:

function routeConfig($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('projects', {
            url: '/projects',
            template : '<ui-view  autoscroll="true" autoscroll-body-top></ui-view>',
            abstract: true,
            title: 'Les projets',
            controller : 'ProjectController',
            sidebarMeta: {
                icon: 'ion-compose',
                order: 250,
            },
        })
        .state('projects.add', {
            url: '/add',
            templateUrl: 'app/pages/projects/add/projects.html',
            title: 'Ajouter un projet',
            sidebarMeta: {
                order: 800,
            },
        })
        .state('projects.list', {
            url: '/list',
            params : { projectId : null},
            templateUrl: 'app/pages/projects/list/listProjects.html',
            title: 'List',
            sidebarMeta: {
                order: 900,
            },
        })
         .state('projects.detail', {
             url: '/detail',
             templateUrl: 'app/pages/projects/detail/detailProject.html',
             title: 'Detail du projet',
        });
    $urlRouterProvider.when('/projects','/projects/list');
}

When attempting to access the child state through the following button:

<button type="button" id="Edit" name="Edit" ng-click="goToPath('#/projects/detailProject', p.id)"class="btn btn-primary btn-raised">Editer</button></div>

`And this is my goToPath method:

$scope.goToPath = function ( path, pid ) {
    $scope.pid = pid;
    $state.go(path, {projectId : pid} );
};

Thank you.

Answer №1

In UI-Router, you specify states and transition to those states. Therefore, your $state.go function should receive a state instead of a path.

<button ng-click="navigateToState('projects.details', projectId)">Edit</button>

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

Exchange one HTML element with a different HTML element

I've been attempting to change an HTML tag using PHP or jQuery. The current default tag is: <li class="dropdown"> <a href="index.html" class="dropdown-toggle"> Home</a></li> My desired replacement for the above HTML tag is: ...

minimize the size of the indigenous foundation input field

Currently incorporating this code snippet into my application: <Item fixedLabel> <Input style={{ width: 0.5 }}/> </Item> The fixedLabel element is extending the entire width of the screen. I have attempted adju ...

Can anyone offer a straightforward method for obtaining JavaScript output in Java within the Eclipse environment?

Currently, I am attempting to retrieve the return value from a JavaScript function that I have created. Although I can achieve this using a complex method involving listeners, I am interested in utilizing Eclipse's Browser.evaluate method. For practi ...

Exploring the features of NextJS version 13 with the benefits

Starting from the 13th step, SSR is utilized by default and in order to opt for client side rendering you must specify it at the top like so: 'use client' Currently, my setup involves TypeScript and styled-component integration. Take a look at ...

Infinite scrolling feature on Kendo UI mobile listview showcasing a single item at a time

Currently, I am utilizing the kendo ui mobile listview and encountering an issue when setting endlessScroll or loadMore to true. The problem arises as the listview only displays the first item in such instances. Upon inspecting with Chrome inspector, I ob ...

Angular Bootstrap Popover will now automatically hide after a short period of time due to the removal of the tt_isOpen variable in ui-bootstrap-tpls-0

I recently attempted to implement the ingenious directive created by runTarm for managing angular-bootstrap-popover-hide-after-few-seconds. While using ui-bootstrap 0.11.0.js presented no issues, transitioning to ui-bootstrap-0.12.0 proved problematic as ...

The UI grid in Angular JS is failing to refresh and display the latest content

I am currently utilizing $http.get to retrieve fresh data from the server for an angular ui grid. Whenever the date in the datepicker is altered, I trigger an ng-change event to initiate another http call for updated content. Although the call is successfu ...

Is it a common issue for a Nuxt.js page using Keycloak.js authentication middleware to reload twice when the browser window is refreshed? Also, it seems that the N

My current setup involves implementing authentication with Keycloak in a Nuxt.js middleware using the code below: import Keycloak from 'keycloak-js' const keycloak = new Keycloak({ url: 'http://localhost:8080/auth', realm: 'd ...

jQuery fails to modify HTML according to its intended purpose

I've been struggling to update a price using JQuery. Even though the code seems fine when I check the console, the HTML doesn't reflect the changes. Additionally, when I try to log console.log(newPrc), it gives an error saying "newPrc" is not def ...

Obtain the URL string without any parameters in Angular 2

I am in the process of developing a web application using Angular2 (v. 2.1.1) for the frontend. Is there a way to extract the base URL, without any parameters, as a string? If my current URL is foo/bar/1/2/3, I am looking for a method to retrieve just fo ...

Leveraging the div value similar to a PHP variable

Here is a script example: <script type="text/javascript"> function showSelected(val){ document.getElementById ('selectedResult').innerHTML = "The selected number is - " + val; } </script> <div id='selectedRe ...

The absence of an object id is a common issue encountered in Django framework when data is sent from Angular

Here is a snippet of code that I am currently working on: { skillName : "Professional Skills" _id : {$oid: "5adf23946ab671bf6cb36aff"} } This code is being sent to the DjangoService function below: @csrf_exempt @api_view(['GET',& ...

What methods are available in JavaScript regex for validating city names?

var cityRegex = /^[a-zA-z] ?([a-zA-z]|[a-zA-z] )*[a-zA-z]$/; is the regular expression I attempted to create. However, it fails when inputting a city name like "St. Petersburg." Update: It seems challenging to create a perfect regex pattern for city name ...

Adding an HTML element to the DOM in an AngularJS directive without using jQuery

Looking to enhance my AngularJS directive by including an svg tag within the current element, currently using jQuery for this purpose. link: function (scope, iElement, iAttrs) { var svgTag = $('<svg width="600" height="100" class="svg">< ...

How to create a smooth scroll effect to a specific section using an <a>

Currently studying web design, I am working on creating a parallax website. I have managed to slow down the scrolling background in certain areas, but I want to enhance it by adding buttons in the header that will smoothly scroll the page to a specific Div ...

"Trouble arises with the match() function in relation to email regex validation

After retrieving the HTML content from a website with my function, I am using String.prototype.match along with a regex rule to extract email addresses from that page. However, the issue is that I am receiving a line that matches the regex but does not con ...

Achieving tabbed code blocks in Gatsby and Asciidoctor.js: A simple guide

As I work on developing a documentation website using Gatsby and Asciidoctor.js, I am in need of displaying code samples for multiple languages in tabbed code blocks. For example, I want to include the same code for both JAVA and Kotlin. Although I have ...

HTML: Body with a larger height than its actual content dimensions

My Chrome browser extension seems to have a body that is much taller than its actual content: https://i.sstatic.net/t44t6.pnghttps://i.sstatic.net/8WjzD.png Even though there are no other parent div elements, the height of the <div id='app'& ...

Add to Firebase reference using AngularFire

Imagine I'm constructing a never-ending scroll of articles. The article's ID is obtained from the URL: var id = $stateParams.id; I aim to startAt that specific index in my Firebase collection and restrict it to 10 items: var limit = 10; var a ...

Unable to update the numerical value in the Material-UI version 5 TextField component

When attempting to display the decimal value 1.0 in the MUI5's TextField component, I encountered an issue. While I can change its value using the icons within the TextField, inputting any value directly seems to be ineffective. Additionally, backspac ...