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

The Express server is failing to deliver a response to the client when using the fetch method

Currently, I am utilizing express for the server side of my project. To send a post request from the client to the server, I am using fetch. The data that I am sending to the server is being successfully transmitted and displayed. However, I am encounteri ...

Utilize the 'response.download' method to retrieve unique data not typically expected for a given request

Each time I try to download a file, the response I get is different. The file is generated correctly every time: user,first_name,last_name,active,completed_training 4,Foo,Bas,YES,YES 5,Ble,Loco,NO,NO 9,gui2,md,NO,NO 3137,foo,baz,NO,NO However, the respons ...

Guide on using jQuery to incrementally cycle through an array using a button

I am facing an issue with iterating through an array of objects using a button. The iteration is skipping 2 on each click instead of moving to the very next record. Can someone help me troubleshoot this problem? Or suggest a better approach to iterate thro ...

Manipulate paths in JS/JQuery by dynamically adding parameters with an indefinite number of values

My JavaScript script relies on an AJAX call that adds a parameter to an HTML request, but I've encountered two issues. I'm struggling to find a straightforward method to retrieve the pathname with parameters. With pure JavaScript, location.path ...

What causes the truncation of the backslash in the string "videos1_visualisation.mp4"?

Check out this example of AngularJS code I've created. The factory contains a list of video sources. var videoPlayer=angular.module('videoPlayer',[]) videoPlayer.controller("videoplayer",["$scope","videolist",function($scope,videolist) ...

Create an input element using JavaScript/jQuery

Looking for some help with Javascript on a simple task. When a specific option is chosen, I want to add an input field to a div element. <select name="amount" > <option value="50">50$</option> <option value="100">100$</o ...

Issue with decodeURI function causing hyperlinks to display as plain text

I have been developing a Sharepoint App that includes a feature to extract contact details from a list on the Sharepoint site. Below is a snippet of my code: var currentOpeningContent = '<h4 onclick="ShowJobDetail(\'' + encodeURI(cu ...

Utilizing Jquery-Menu-Aim to assign values to child scopes

Currently, I am in the process of developing a directive for jQuery-menu-aim. While my current implementation is functioning as intended, I can't help but feel that finding and setting values on the child scope seems like a workaround. You can view m ...

Using Protractor to Verify Text Inside an Element

Is there a way to verify if a button contains text without specifying the actual text? I want to ensure that the button has text but not necessarily check for specific content as it may vary on different pages. Ideally, I'm looking for a dynamic solut ...

"Sending an array in a POST request using Javascript and processing it on the server

I am trying to use ajax to send an array. Let's say the array looks like this: var anotherOne = 'anotherOneData'; var documents = ['banana', 'apple', 'monkey']; I successfully sent both a normal value and an a ...

Is it possible to validate input only during insertion in Objectionjs without validation during updates?

const BaseModel = require("./base_model.js"); class CustomerModel extends BaseModel { static get tableName() { return "customers"; } static get jsonSchema() { return { type: "object", required: ['na ...

Creating an interactive webpage with Javascript and HTML

I'm facing a challenge with my component setup, which is structured as follows: import { Component, VERSION } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ ...

Exploring Angular: tackling multiple controllers in a single view or route

We are currently in the process of developing a large Single Page Application (SPA). The application is structured using widgets/components, each with its own template and controller. These components can be nested within the same route. For instance, with ...

Incorporated new code into the website, functioning properly, although it appears to keep scrolling endlessly below the footer

My website is experiencing a strange issue where the page seems to keep extending beyond the footer due to some JS code. I am not very familiar with JavaScript and have tried different solutions without success. I have searched extensively online for a so ...

Purge POST request cache in Node.js

Currently, I have implemented nodemailer to enable users to contact me via email. Once the form data is submitted successfully, the page redirects to my homepage as intended. However, if an attempt is made to refresh the page, a confirmation alert pops up ...

Is it impossible to extend a Typescript class with an overriding method that uses a different parameter?

I am currently working on a Typescript MVC app and encountering an issue. When I try to extend my BaseController and override the ajaxMethod with different parameters, my transpiler throws an error. Any help would be appreciated. Below is the code snippet ...

Exploring date comparison in AngularJS

I've encountered an issue while using ng-show in a page that I'm currently designing: <td ng-show="week.EndDate > controller.currentDate"> The week object has a property called EndDate, and the value of currentDate is being set in my c ...

Step-by-step guide: Uploading files with Ajax in Codeigniter

I am facing an issue with updating data and uploading an image when editing a row in my grid. Although the data is successfully updated, I am encountering difficulties in saving the image file to a folder. Here is what I have tried: While using AJAX, I ...

Promise Pending awaiting response from function

Could someone please explain why the code I have written below is returning a Promise pending value for the 'out' variable? var out = dbConn.connect().then(function (){ var request = new sql.Request(dbConn); request.input("termin ...

Angular: Leveraging real-time data updates to populate an Angular Material Table by subscribing to a dynamic data variable in a service

Seeking guidance on how to set up a subscription to a dynamic variable (searchData - representing search results) for use as a data source in an Angular Material Table. I have a table-datasource.ts file where I want to subscribe to the search results from ...