What are some ways to create a ui-view that maintains its content without refreshing automatically?

My application utilizes 2 ui-views to display content - one for the friendlist and the other for a specific view:

<div class="container-fluid h100">
  <div ui-view class="h100">

  </div>
  <div ui-view="connected">

  </div>
</div>

The ui-view connected is only shown when the user is connected to the app.

However, I am facing an issue where all views are reloaded, including the friendlist, when I change the URL. I am looking for a way to prevent this behavior. Any suggestions? Perhaps restructuring the code could help.

The state configuration is as follows:

.state('homepage', {
  url: '/homepage',
  views: {
    "connected" : {
      templateUrl : './src/friendlist.html',
      controller : 'NavRightController'
    },
    "" : {
      templateUrl : './src/homepage.html',
      controller: 'HomePageController',
    }
  }
})
.state('settings', {
  templateUrl: './src/settings.html',
  controller: 'SettingsController',
  url: '/settings',
  views: {
    "connected" : {
      templateUrl : './src/friendlist.html',
      controller : 'NavRightController'
    },
    "" : {
      templateUrl : './src/homepage.html',
      controller: 'HomePageController',
    }
  }
})

Answer №1

Personally, I believe it's best to have a single ui-view directive for every HTML page and take advantage of the Nested views feature of the UI Router.

For your situation, consider using the friendlist as the main parent view with the others serving as "child views".

I hope this advice proves helpful for you.

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 children component is not recognizing the function being passed through this.props.children, resulting in an

Looking for a solution that involves passing a function to this.props.children? Check out the code snippet below: updateBarTitle(barTItle){ this.setState({barTItle}); } render(){ const children = React.Children.map(this.props.children, function (chi ...

Divs sliding out of alignment

I am experiencing an issue with the scrolling behavior of a wrapper div that contains two nested divs. Specifically, when I scroll the wrapper horizontally on Android devices, the header section and content section seem to be out of sync and there is a not ...

Is there a way to reverse the process of Date.parse?

After converting a date to a number with the following code: Date.parse(doc.createdAt); I receive this result: 1576699528000 It seems like the number becomes a string when passed from the server to the front end and back to the server. How can I conver ...

Ways to determine the height of a row within a flexbox

Is it possible to obtain the height of each row within a flexbox container using JavaScript? For instance, if there are 3 rows in the container, can I retrieve the height of the second row specifically? ...

What are some ways to prevent Visual Studio from adding an extra space in JavaScript code during the build or rebuild process?

In my Visual Studio 2019 Enterprise setup, I have noticed that when I build or rebuild my ASP.net 4 MVC solution, my JavaScript files are regenerated by TypeScript. The issue is that the new JavaScript files always end up with a single trailing space after ...

Updating documents in a mongoDB collection can be done by simply

I require an update to my database that will modify existing data, as illustrated below: existing data => [{_id:"abnc214124",name:"mustafa",age:12,etc...}, {_id:"abnc21412432",name:"mustafa1",age:32,etc...}, {_id ...

Add HTML and JavaScript code dynamically with JavaScript

Currently, I am working on a project that involves an HTML table with some basic JS interactions triggered by user clicks. The structure looks something like this: htmlfile.html ... ... position action ...

What is the best way to extract values from promises that are still pending?

Having some issues with the code below and unable to achieve the desired output. Any help in identifying what's wrong would be greatly appreciated. Thanks! Here is the code: // Making http requests const getJSON = require('get-json'); ...

Trouble with second function invocation in JavaScript

After creating two sets of arrays and passing them into different functions, I noticed some strange behavior. The first time I called the functions for scores1, everything worked perfectly. Likewise, the second time I called the first function (for Scores2 ...

Error 404: Page not found. Sorry, we couldn't locate the Node JS and Express resource

I have been trying to access the routes /api and /api/superheroes, but I keep encountering an error message whenever I try. Not Found 404 NotFoundError: Not Found at C:\Users\mikae\Desktop\Project\node-express-swig-mongo\a ...

What could be causing express to have trouble finding the ejs file in the views directory?

Recently delved into the world of learning NodeJS and Express. // Working with express framework var express = require("express"); var app = express(); app.get("/", (req,res) => { res.render("home.ejs"); }) //Setting up port listening app.listen ...

Setting up an SSL certificate for an Express application: A step-by-step guide

I am currently trying to set up my Express server in order to pass the SSL certificate and transition from http to https. After going through the Express documentation, I still haven't been able to find a suitable solution. While some suggestions lik ...

What is the best way to establish a default search query within the vue-multiselect component?

I have incorporated vue-multiselect into my project. You can find more information about it here. This is a snippet of my template structure: <multiselect v-model="value" :options="options" searchable="true"></multiselect> When I open the mu ...

Is there a method to incorporate a scroll event into the ng-multi-selectdropdown, a npm package?

Query: I need to incorporate a scroll event in the given html code that triggers when the div is scrolled. However, I am facing issues with implementing a scroll event that works when the elements are being scrolled. <ng-mult ...

Having trouble getting CSS animation to work on Mozilla using mozAnimationName?

<style> @keyframes shake { 0% { -moz-transform:scale(0);opacity:0; } 25% { -moz-transform:scale(1.3);opacity:1; } 50% { -moz-transform:scale(0.7);opacity:1; } 75% { -moz-transform:scale(2); ...

Tips for updating checked checkboxes in a php mysql database

When submitting an HTML form with a selected checkbox, update the values of the selected checkboxes in a MySQL database. For example: update enquires set status = '2' where id in (selected checkbox values) View the screenshot of the checkbox Vi ...

use ".otherwise" or /** with the latest version of Angular2 Router to redirect non-routes using wildcards

Can anyone provide guidance on using wild cards to route in the new Router when a non functional route is specified? Similar to the .otherwise method in Angular 1.X router or /** in previous beta router. Additionally, any example or Plunker code would be ...

The function type '(state: State, action: AuthActionsUnion) => State' cannot be assigned to the argument

I have encountered a persistent error in my main.module.ts. The code snippet triggering the error is as follows: @NgModule({ declarations: [ PressComponent, LegalComponent, InviteComponent ], providers: [ AuthService ], imports: ...

How can I create a "suggest" command using Discord.js?

How can I improve my Discord.js code for a suggest command that handles two types of suggestions - support server and bot? Currently, my code is not working as expected. Here is what I have: if (command === "suggest"){ const type = args.join(" ") ...

When using Vuepress behind a Remote App Server, pages containing iframes may return a 404 error

Creating a static website using Vuepress was a breeze, especially since I included a dedicated section for embedded Tableau dashboards. The website functioned perfectly when accessed online without any issues, displaying the Tableau dashboards flawlessly. ...