Encountering a double page load issue while utilizing angular ui-router in combination with "resolve" feature

I am currently utilizing Angular version 1.5.5, Angular-ui-router version 0.2.18, angular-meteor-promiser version 1.1.0, and meteor version 1.3.3

Within my application, I have a route defined as follows: (There are various other states):

function routerConfig($stateProvider, $urlRouterProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
    $stateProvider
      .state('auditionExtExec', {
        url: '/AuditionExtExecute/:id',
        templateUrl: 'client/auditions/auditionExtExec.html',
        resolve: {
          auditionsubs: function($promiser) {
            "use strict";
            console.log('in resolve');
            return $promiser.subscribe('auditions');
          },
        },
        controller: 'AuditionExtExecCtrl',
        controllerAs: 'vm'
      })

The controller for this route is:

angular
  .module('brgo')
  .controller('AuditionExtExecCtrl', function($state, $stateParams, $scope, $reactive, $promiser, auditionsubs) {

    var vm = this;
    $reactive(vm).attach($scope);
    vm.auditionId = $stateParams.id;

    vm.subscribe('auditions');

    vm.start = false;
    vm.auditionResults = {};
    var currentDate = new Date();

    vm.autorun(() => {
      vm.audition = Auditions.findOne({
        _id: vm.auditionId
      });
    });

    vm.addNewExecution = function() {

      vm.auditionResults.auditions = angular.copy(vm.audition.auditions);
      AuditionExecs.insert(vm.auditionResults);


    };

    vm.startaudition = function() {

      vm.start = true;

    };

  });

The purpose of this page is to display the details from the audition collection in the MongoDb table and save results to the AuditionExec collection.

While everything appears to be functioning correctly when the application runs, there is an issue where if I navigate to the auditionExtExec state and copy the URL to a new window, the view in the new window is duplicated. Removing the $promiser from the resolve seems to resolve this duplication problem.

Answer №1

Once promiser.subscribe is removed, the issue vanishes into thin air

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

Mastering the Art of jQuery Post with Iteration and Result Utilization

I am facing an issue with my code function fetchInfoFromDB() { let body = ""; let text = ""; $("tr").each(function (index) { let code = $(this).children("td:nth-child(2)"); $.post("http://urltogetdatafromdatabase.com/getinfo.ph ...

Looking to dynamically update a date variable based on user selection from a drop-down menu in PHP

I am currently working with a PHP file (index.php) which features a title bar displaying the date in the format (MM YYYY). The dates themselves are extracted from another PHP file named latest_update.php. Within the latest_update file, the dates are specif ...

Encountering issues with displaying the French character 'à' on JSON format

My JSON String 'd'instruments cordes à' contains a French character (à) that is causing a JSON error when displayed. I need to show the correct character in my UI. ...

Tracking hits with Node.JS Connect

Feeling a bit bored, I decided to create a connection counter (shown below) that logs each client connection as two different connections. Can anyone explain why this unexpected behavior is occurring? var http = require('http'); var count = 0; ...

The utilization of the Node Cluster module is not supported when using Passenger

I am currently working with node.js express passport and recently integrated rate-limiter-flexible library. However, I have encountered an error message: server.js const { RateLimiterMemory, RateLimiterRes } = require('rate-limiter-flexible'); ...

Can a for loop be implemented within a mongoose schema method?

Is there a way to modify this for loop so that it runs through the entire array instead of adding one by one? Any suggestions? EndorsedSkillSchema.methods = { async userEndorsedSkill(arr) { for (var i = 0; i < arr.length; i++) { const skil ...

How can I dynamically add a new record to a store in Extjs 6.2?

After utilizing Ext.js 4.2, I noticed that adding a new record to the store dynamically updates my grid immediately with just this simple line of code: me.getStore().insert(0, rec); However, upon using Extjs 6.2, I found that while the new record is adde ...

No information available at the moment

When the data is not present, it displays as "display none"... However, I want it to show "no data found" This is the current code if (a.innerHTML.toUpperCase().indexOf(filter) > -1) { li[i].style.display = ""; } else { li[i].styl ...

Tips for integrating native transitions into Ionic modals

I developed an ionic application and noticed that the transitions were quite slow in the beginning. To improve this, I decided to use the ionic-native-transitions plugin. After implementing the plugin, the app transitions became much smoother, and now I am ...

The ScrollToTop feature in MUI component seems to be malfunctioning when paired with the useScrollTrigger hook

I am in the process of developing a custom ScrollToTop component using MUI's useScrollTrigger hook. More information can be found at this link Feel free to check out the sample code here: https://codesandbox.io/s/stackoverlow-mui-usescrolltrigger-er9 ...

Navigating data flow between tabs in Ionic

I am working on a straightforward project that involves 3 tabs. One of the requirements is to move an item from the first tab to the second tab and vice versa when a button is clicked, with a notification sent to the server upon this action. Is there a way ...

Continue scrolling the HTML page before it reaches the end

https://i.sstatic.net/6iBof.png I am currently troubleshooting an issue with my chat thread. At the moment, the chat window automatically scrolls up when it reaches the bottom of the page to ensure it is always visible. However, there is a problem where ...

Having trouble loading CSS and JavaScript files in CodeIgniter?

In my project, I am utilizing Bootstrap as a template. However, when attempting to access Bootstrap in Codeigniter, the page fails to load the CSS and JavaScript files. I have included the URL in autoload.php $autoload['helper'] = array('url ...

Creating a nested function and utilizing the return statement in JavaScript

I am facing an issue with my custom function that contains an ajax call. I need to retrieve a variable from the ajax function within my custom function, but I'm unable to do so. Why is this happening? Possible solution 1: <script> function ...

Error: Promises must be managed correctly

I've been working on a timer-based function that is supposed to run once a week and create almost identical copies of existing documents. However, every time I try to execute it, I encounter the error message "Promises must be handled appropriately." ...

Navigating boolean data extracted from JSON strings with angular expressions

Currently, I'm extracting information from a JSON string with Angular and experimenting with my application. Task Status: {{task.completed}} // output is either true or false I aim to accomplish the following: If task completed == true, display "c ...

Resolving type errors in Typescript React Tabs proves to be a challenging task

I am currently in the process of converting a Reactjs Component to a Typescript Component Below is the Tabs Component: <Tabs> <Tab label="one"></Tab> <Tab label="two"></Tab> </Tabs> import React, { ...

In the generated JavaScript code, TypeScript displays imported interfaces and types in a list format

In my module A, I have a set of classes, types, and interfaces being exported: export class Event { // empty } export interface EventHandler { handle(event: Event): void } export type EventCallback = (event: Event) => void These can be utili ...

Is it possible to utilize _app.js for global data sharing within my app?

I am in the process of developing a small chat application that will utilize sockets. In order to achieve this, I am planning to use both Context API and a global socket variable. As this is my initial experience working with Next.js, I am uncertain about ...

Looking to ensure that the appropriate error validation message displays when an incorrect username is entered and submitted within an Angular JS application

I am working on binding the error message and testing it. Here is the code snippet I am using: <div class="col-md-9 col-xs-12"> <strong class="text-danger ng-binding" title="Invalid Username"> ...