Modifying a single route among several nested routes with specific names

My template includes various named, nested views:

Template 1:

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

Template 2:

<header></header>
    <div ui-view="left"></div>
    <div ui-view="canvas"></div>
    <div ui-view="right"></div>
    

Here is the configuration setup:

.state("metricDashboard", {
            url: "/metric-dashboard",
            css: { href: "core/metric-dashboard/style.css" },
            views: {
                "": {
                    templateUrl: "core/metric-dashboard/view.html",
                    controller: 'MetricDashboard',
                },
                "left@metricDashboard": {
                    templateUrl: "core/metric-dashboard/partials/left.html",
                    controller: "MetricDashboardLeft",
                },
                "canvas@metricDashboard": {
                    templateUrl: "core/metric-dashboard/partials/canvas.html",
                    controller: "MetricDashboardCanvas"
                },
                "right@metricDashboard": {
                    templateUrl: "core/metric-dashboard/partials/right.html",
                    controller: "MetricDashboardRight"
                }
            }
        })
    

I am trying to figure out how to modify an individual route. For example, changing "left@metricDashboard" without affecting the "canvas" and "right" routes. I have not been able to find a way to do this without creating a new state and redeclaring all the routes.

Answer №1

So, it seems like you're interested in creating a new state that will only affect one of the views instead of all of them.

We can name this new state left and make it a child of the metricsDashboard state.

.state("metricDashboard", {
    url: "/metric-dashboard",
    css: { href: "core/metric-dashboard/style.css" },
    views: {
        "": {
            templateUrl: "core/metric-dashboard/view.html",
            controller: 'MetricDashboard',
        },
        "left@metricDashboard": {
            templateUrl: "core/metric-dashboard/partials/left.html",
            controller: "MetricDashboardLeft",
        },
        "canvas@metricDashboard": {
            templateUrl: "core/metric-dashboard/partials/canvas.html",
            controller: "MetricDashboardCanvas"
        },
        "right@metricDashboard": {
            templateUrl: "core/metric-dashboard/partials/right.html",
            controller: "MetricDashboardRight"
        }
    }
})
.state("metricDashboard.left", {
    url: "left",
    views: {
        "left@metricDashboard" : {
            templateUrl: "some.html",
            controller: "AwesomeCtl",
            controllerAs: "awe"
        }
    }
})

By navigating to this new state, only the left view will be updated while the others will remain as defined in the parent state metricDashboard.

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

Troubleshooting the Owl carousel's responsiveness with a div width of 1170px

Whenever my display size is less than 1170px, the width of the owl carousel div overflows. How can I fix this issue? jQuery(document).ready(function($) { "use strict"; // CUSTOMERS TESTIMONIALS CAROUSEL $('#customers-testimonials&a ...

Encountering the following error: Exceeded maximum call stack size limit

Currently, I am attempting to tackle a specific problem on LeetCode. This particular challenge involves calculating the power of x. However, upon executing my solution, an error message is displayed: RangeError: Maximum call stack size exceeded Here&apos ...

Managing a JSON request from an AJAX form using PHP - the ultimate guide!

I'm encountering some issues with my PHP handler. Here is the code snippet for my handler: <?php // Creating headers $headers = array( 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8&a ...

Show another default value once an option has been chosen

I am looking to create a functionality where, after a user selects an option, the input will change to display "select another option" instead of showing the name of the selected option. For example: <select> <option value="" selected&g ...

Issues with local storage ternary expression in React are causing unexpected behavior

I am attempting to accomplish this task. const userToken = localStorage.getItem('token') {userToken.length ? null : <div className='registerLogin'> Register... </div> } The ternary operator is not working ...

The process of using Jest to test whether a React component correctly renders a list

I've been diving into the world of unit testing and recently developed a small React application that showcases a list of Pokemon. My goal is to create a unit test that verifies if the list renders correctly. However, when I generate a snapshot, it on ...

Is it possible to set the radius of a d3.js circle using a style attribute?

Learn more about styling in d3.js with this detailed guide that explains how style attributes can be leveraged to customize the look of a circle, including fill color, stroke color, and stroke width. Is it possible to adjust the radius of a d3.js circle u ...

Implementing experimental decorators and type reconciliation in TypeScript - A step-by-step guide

My basic component includes the following code snippet: import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; export interface Props { }; @withRouter export default class Movies extends R ...

When integrating React with Tawk, the user's name and email are automatically encoded before being sent

My code within the componentDidMount() function initializes a widget popup when the page loads. It then sets the name and email using parameters received from the previous page. const fullName = this.state.data[0]; console.log(fullName); const e ...

I encounter an error message stating "Cannot read property 'push' of undefined" when trying to add an item to a property within an interface

I have a model defined like this : export interface AddAlbumeModel { name: string; gener: string; signer: string; albumeProfile:any; albumPoster:any; tracks:TrackMode[]; } export interface TrackMode { trackNumber: number; ...

Setting up 'ngProgress' as a loader in my project using the 'ngbp boilerplate' is straightforward and easily customizable

Currently, I am utilizing the 'ngbp' angular boilerplate from GitHub to develop my project. My goal is to implement ngProgress for displaying a loader when navigating between sections. I have successfully installed ngProgress via bower and ensur ...

What is causing this get method to return such a message?

One of my functions tabulates user-specific data using a GET method that sends a query parameter userId: <script> let thisArray = [] let = userId = $('#userId').val(); $.ajax({ method:&ap ...

Experiencing the issue of receiving unexpected commas following a div

Here is the code written in TypeScript for creating an HTML table that displays items from nested objects. The code is functional, but there seems to be an issue with extra commas being printed which are not part of any specific line being executed. im ...

Oops! An error occurred when attempting to log in with an unidentified authentication method called "local"

After following a tutorial to build my project, I encountered an issue with the login functionality. While the signup process works fine, attempting to log in a registered user using postman results in the error: Error: Unknown authentication strategy "loc ...

What is the best way to combine a collection of strings and HTML elements in a React application?

I am facing a challenge with my list of names. I typically use .join to add commas between each name, but one specific item in the list needs to display an icon of a star next to it based on a certain condition. The issue is that using join turns everyth ...

Embed HTML code into a React/Next.js website

I've been given the task of enhancing the UI/UX for an external service built on React (Next.js). The company has informed me that they only allow customization through a JavaScript text editor and injecting changes there. However, I'm having tro ...

Creating interactive avatars with Material UI and React to provide a dynamic user

I have developed a simple form validation application using react.js. Each user has a unique profile containing their personal information. I am looking to utilize the first letter of the user's name, for example Peter, where the letter "P" would be d ...

404 error occurs when routing in Express.js is unable to find the

Seeking Assistance I am encountering an issue with my express.post() routing as it returns a 404 state. Current Implementation The code in my server.js file seems fine, but I am facing this routing problem. // Required modules and database connection v ...

Error encountered: Unable to access undefined properties while attempting to make an API call to AirTable using NextJS version 13.4

Currently in the process of learning how to use the App router with NextJS 13.4, I encountered an issue while attempting to make an external API call. Even though I am getting all the data correctly from Airtable, Next throws an error that disrupts my try ...

Applying specific style properties in styled-components can vary based on certain conditions

Is it possible to apply multiple properties at once? const Button = styled.div` color: blue; opacity: 0.6; background-color: #ccc; ` I want to apply styles for the active state without having to specify conditions for each property individually. Ho ...