explore a nested named view using ui-router

My app has a view called mainContent.

    <div class = "wrapper"
         ui-view = "mainContent">
    </div>

There is only one route for this view.

    $stateProvider
        .state("home",
        {
            url: "/home",
            views: {
                'mainContent': {
                    templateUrl: "app/home/home.html"
                }
            }
        });

I am loading home.html into the named view mainContent, which also contains a named view appContent.

home.html

    <div class = "row"
         ui-view = "appContent">
    </div>

The routes for the nested named view appContent are as follows.

    $stateProvider
        .state("request",
        {
            parent: "home",
            abstract: true,
            url: "/request"
        })
        .state("request.create", {
            url: "/create",
            views: {
                appContent: {
                    templateUrl: "app/requests/create/createRequest.html",
                    controller: "RequestController as vm"
                }
            }
        });

However, when I try to load , the RequestController is not created and the view createRequest.html is not loaded.

To navigate from the view to the request.create state, I use:

<a ui-sref = "request.create"><i class = "fa fa-plus"></i>New</a>

Thank you.

Answer №1

Your "request" section should have its own designated template with a ui-view element to display its child view.

$stateProvider
    .state("home",
    {
        url: "/home",
        views: {
            'mainContent': {
                template: "<div class ='row' ui-view ='appContent'></div>"
            }
        }
    })
    .state("request",
    {
        parent: "home",
        abstract: true,
        url: "/request",
        views: {
            'appContent': {
                template: "<div class ='row' ui-view ='requestContent'></div>"
            }
        }
    })
    .state("request.create", {
        url: "/create",
        views: {
            'requestContent': {
                template: "<p>Create Request</p>"
            }
        }
    });

I've tested this setup and it is functioning correctly. Here's the proof: http://jsfiddle.net/eD3MU/373/

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

Replace HTML elements with AJAX and JavaScript

Working with MySQL data in pyramid presents a challenge as I need to dynamically change an HTML if statement based on the results from JS ajax calls. The main page receives data from views.py and passes it to the .mak script. The key views here are the ma ...

Tips for getting the sum of an array using the reduce method in Vue.js and returning the result array

As someone new to JavaScript, I apologize if my description of the issue is not clear. It's challenging for me to explain the problem I am facing. I have a computed function where I use the reduce method to iterate over my objects, perform calculatio ...

The use of JSON.parse does not support parsing URL links

As a junior developer specializing in Javascript and Google Apps Script, I decided to enhance the functionality of my Google Sheets by tracking the last modification time of URLs stored in them. Although I attempted to create a script for this task, it see ...

Any property modified by an event handler will consistently appear in its original form

Every second, a simple function is called using setInterval, with the goal of determining mouse or keyboard activity. The variable that tracks the activity is updated, but it always remains set to 0 despite the fact that console.log statements are being e ...

Angular 1 Makes Drag and Drop a Breeze

I am exploring a new feature in Angular and trying to create a drag and drop functionality between 2 tables without sorting. Despite no errors in the console, I cannot see any results being displayed. My slight variation in requirements is causing some con ...

Configuring Jest unit testing with Quasar-Framework version 0.15

Previously, my Jest tests were functioning properly with Quasar version 0.14. Currently, some simple tests and all snapshot-tests are passing but I am encountering issues with certain tests, resulting in the following errors: console.error node_modules/vu ...

changing the visible style of a div element using JavaScript

I'm having an issue with a link on my webpage that is supposed to show or hide a <div id="po" style="display:none;">some html</div> element. The first time I click the link, the div displays properly. However, after tha ...

Even with manual installation, the npm package still encounters dependency errors

Having trouble implementing the Imgur package from NPM into my Angular web app. The installation and import seemed to go smoothly, but when initializing a variable with the package, I encounter compile errors pointing to missing dependencies like 'cry ...

Having trouble with changing text in a link with an onclick event?

When I click on the link, I want the text to change to the second span. However, this functionality is not working. Code var reload = false; $('#change').click(function() { reload = !reload; $('#change').click(function() { ...

JavaScript Hangman Game Malfunctioning

I am in the process of creating a basic hangman game to be played on a web browser. Whenever the user clicks a button, it triggers a function called pickWord(): <button onclick="pickWord()" id="restart">Choose A Word</button> This functi ...

What causes the issue when attempting to import multiple CSS files in a Vue.js project using @import more than once?

Currently, I am working on a project that involves one main component and several child components. These components require custom CSS files as well as additional vendor CSS files. A challenge I encountered is that I cannot use the @import "path/to/css/fi ...

The dynamic route parameter does not currently have compatibility with languages that utilize Unicode characters apart from the English

NextJS 13 (beta) Official Documentation provides information on dynamic route parameters in this link. Clarification: app/shop/[slug]/page.js To retrieve the slug, use params.slug. Example: app/shop/this-is-shop/page.js In this case, params.slug will o ...

Is it feasible to maintain a variable as a reference across views while utilizing ng-view?

I am facing a unique challenge: I have a webpage with two tabs that need to utilize ng-view from AngularJS. The twist is that both tabs must share the same variable, similar to referencing a variable in C# using the "ref" keyword. If you want to see an ex ...

jQuery conceal input field after it has been displayed

I've created an HTML form with two different sections for search purposes. The first section displays basic fields, and by clicking on "Advanced Search" (in my case, "Расширенный поиск"), additional fields are revealed. Everything work ...

Vue: Develop a master component capable of displaying a sub-component

Is there a way to design a main component that is able to accept and display a subcomponent? Take the following scenario for instance: <Container> <Item/> <Item/> <SubMenu/> <Btn/> </Container> ...

Transforming JSON data into XML using Angular 7

It turns out the xml2js npm package I was using doesn't support converting JSON to XML, which is exactly what I need for my API that communicates with an application only accepting XML format. In my service file shipment.service.ts import { Injecta ...

Unable to retrieve the value property from document.getElementById as it is null

Can someone help me with reading the input field value in my code? <input type="text" name="acadp_fields[1200]" class="text" placeholder="" value="December 26, 1969"> Here is the code snippet I am us ...

Problem encountered while revalidating Next.js and Sanity documents through a webhook

I'm currently developing a Next.js 13 project that utilizes Sanity as its CMS and is deployed on Vercel. To ensure that components and pages are revalidated whenever a new testimonial is added, updated, or removed in Sanity, I have configured a webhoo ...

"Implementing a conditional statement in JS / JQuery without the need to

I'm interested in finding out if it's possible for a function's conditional statement to display the result whenever the argument is true, without needing to call the function again. Here is an example of such a statement: if($('#a&ap ...

Webpack development server is not recognizing changes to the SCSS files

I successfully compressed and compiled my JavaScript and SCSS files using webpack. The SCSS file is extracted by the 'extract-text-webpack-plugin' into an external CSS file. Below is the code snippet: var path = require('path'); var we ...