Giter VIP home page Giter VIP logo

Comments (3)

christopherthielen avatar christopherthielen commented on September 17, 2024 2

I've demonstrated view targeting in this fork of the tutorial

See the views guide for more details on view targeting

from core.

christopherthielen avatar christopherthielen commented on September 17, 2024 1

Hi @SamanthaAdrichem

Nested states in UIRouter usually imply that you also want nested views. That is, you want UserDetailComponent to be rendered inside a UIView that UsersComponent renders. This style is shown in Hello Galaxy tutorial).

However, it sounds like you want UserDetailComponent to replace the UsersComponent when /admin/users/:userid is active. There are two common ways to achieve this.

  1. The first is what you've demonstrated in your last snippet, making the list and detail states siblings:
{
    name: 'admin.users.overview',
    url: '/', // becomes /admin/users/ due to tree
    component: UsersComponent
},
{
    name: 'admin.users.detail',
    url: '/:userId', // becomes /admin/users/:userId due to tree
    component: UserDetailComponent
},

Note: I changed this to url: '/' to avoid overview in the url.

  1. The second is to keep the parent/child relationship but use view targeting to target the UIView rendered by the admin state.
{
    name: 'admin',
    url: '/admin',
    component: AdminDashboardComponent
},
{
    name: 'admin.users',
    url: '/users',
    component: UsersComponent
},
{
    name: 'admin.users.detail',
    url: '/:userId',
    views: {
      '@admin': {
        // renders into the unnamed UIView from the 'admin' state.
        // the component from the deepest nested state "wins"
        component: UserDetailComponent
      }
    }
  },

from core.

SamanthaAdrichem avatar SamanthaAdrichem commented on September 17, 2024

Thank you for the explanation

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.