AngularJS - Unexpected events are triggered on the parent window when clicking in a new browser window where a controller is open

Trying to implement a requirement for an audit log page with a button that opens logs in a new browser window while continuing other activities on the main application. Utilizing ui-router and angularjs (1.6), here is the code snippet -

Controller Route -

 .state('auditlog', {
        url: '/auditlog',
        templateUrl: 'app/system/audit/audit-log.html',
        controller: 'AuditLogController',
        controllerAs: 'al'
    })

Code for button click event in another controller -

unDockEventsPanel(event) {
    let location = this.$state.href('auditlog');
    this.$window.open(location, '', 'scrollbars=no,fullscreen=yes,toolbar=no');
}

HTML snippet -

<i class="Icon-MoveOut Icon-Large icon-btn" ng-click="eventsPanelVM.unDockEventsPanel($event)">

Clicking the "MoveOut" button triggers the unDockEventsPanel() method opening a new window displaying content from the "auditlog" route definition.

The issue arises when interactions on one window affect the other unexpectedly. For example, selecting a button on the child window may also highlight a control on the parent window, causing confusion. It seems there is overlap of controls and events between the two windows due to them sharing the same instance of the application/controller. However, isolating them proves challenging.

Appreciate any assistance in resolving this matter.

Answer №1

It seems like the issue stems from utilizing '$state'

let pageLocation = this.$state.href('auditlog');
this.$window.open(pageLocation, '', 'scrollbars=no,fullscreen=yes,toolbar=no');

Referencing information from the angular-ui github wiki

Upon state activation, its templates are automatically included in the ui-view of its parent state's template.

I recommend exploring alternatives to using $state by employing traditional Javascript for navigating to the new window

window.open("{yourURL}/auditlog", 'scrollbars=no,fullscreen=yes,toolbar=no');

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

Withdrawal of answer from AJAX request

Is there a way to create a function that specifically removes the response from an AJAX call that is added to the inner HTML of an ID? function remove_chat_response(name){ var name = name; $.ajax({ type: 'post', url: 'removechat.php ...

Errors encountered when using Puppeteer on Kubernetes: "Detached navigation frame" and "Attempting to access main frame too soon"

I have been attempting to execute a nodejs based Docker container on a k8s cluster, but I am encountering persistent errors: Navigation frame was detached Requesting main frame too early In an effort to resolve this issue, I have condensed the code to ...

What is the best method to select a sibling element by its class name and then conceal it using solely Javascript?

Here is the HTML structure I am working with: <div id="xyz"> </div> <div class="content"> </div> I am looking to hide the element with a class named content based on the sibling element ID, which is xyz. In jQue ...

Storing and accessing mixed file types in a web application using either a Blob or File System

Hey there, I am currently in the process of creating a web application that utilizes Spring MVC, Hibernate, MySQL, and AngularJS technologies. As I navigate through this project, I have encountered a specific issue that requires resolution. Imagine a scen ...

Retrieval of jQuery remove() method

Essentially, I am utilizing an OnClick function to delete a DIV. Once the OnClick is triggered, it invokes the remove() jQuery function to eliminate the div. Below is my code that implements the removal using remove(): <div id="add"> <button typ ...

Error Alert: jQuery Ajax Not Executing

Looking to send form data to PHP using jQuery. Check out the code below. -------------HTML FORM-------------- <div id="createQuestionBlock"> <form id="createQuestionForm" action="" method="POST"> Question Code: <input id="code" ...

Guide on inserting text within a Toggle Switch Component using React

Is there a way to insert text inside a Switch component in ReactJS? Specifically, I'm looking to add the text EN and PT within the Switch Component. I opted not to use any libraries for this. Instead, I crafted the component solely using CSS to achie ...

Ways to eliminate the absence of the 'Access-Control-Allow-Origin' header in an error message when using a Java-based web-service server

I'm currently working on developing a webservice using Java as the server and Javascript as the client. My goal is to send a Post request with JSON data and receive a Post response with JSON data from the server. However, since the client and server h ...

Content sliding to the left due to modal prompt

I've searched through various questions and answers but haven't been able to resolve this issue. There's a modal on my page that is causing the content to shift slightly to the left. I've created a sample fiddle, although it doesn&apo ...

Sending a list of strings to a Controller in MVC 3 Razor

I am encountering an issue when passing a list of strings into a controller in MVC 3 Razor. I am using jQuery to set the values, but for some reason, the first value is always false on the server side. Here is my code: Class: public class ListFieldInf ...

Utilizing ng-switch for handling null values or empty strings

Can anyone assist me with this issue? I have a variable called $rootScope.user = {name:"abc",password:"asd"}. When a service response occurs, I am dynamically creating a rootscope variable by assigning it. How can I use ng-switch to check if the variable h ...

Endless AngularJS loop using ng-view

I recently started experimenting with AngularJS for a new project I am working on, but I have encountered a problem when dealing with routes and views. For the sake of simplicity, I have minimized this example to its basic form, yet the issue persists. Th ...

Running into issues on Heroku with Node, Gulp, and Browserify: Module Not Found Error

My asset building process relies on Gulp. Specifically for Javascript, I have a task set up with Browserify to handle all code dependencies. While everything runs smoothly locally, deploying to Heroku results in a Gulp failure with the following error: 2 ...

Sign up for your own personalized Express and HBS helper now!

As a newcomer to Node, I appreciate your patience with me. I recently utilized the express generator module with the -hbs flag to switch from the default templating engine to Handlebars. Currently, I am attempting to register a custom helper to enable me ...

Occasionally, I encounter a parse error while trying to load a script

Have any developers out there experienced a situation where, upon reloading a script in the browser, a PHP error pops up? The error message usually reads: Parse error: syntax error, unexpected $end in /.../ on ... Interestingly, this error seems to oc ...

Display every even number within the keys of objects that have values ending with an odd number

I need a way to print all even values that are paired with odd values in the object keys, but my code only works for arr1, arr3, and arr5. Can someone help me adjust the 'let oddArr' method (maybe using a loop) so that it will work for any array ...

A different approach to fixing the error "Uncaught (in promise) TypeError: fs.writeFile is not a function" in TensorFlow.js when running on Chrome

I've been attempting to export a variable in the TensorFlow posenet model while it's running in the Chrome browser using the code snippet below. After going through various discussions, I discovered that exporting a variable with fswritefile in t ...

Exploring the process of generating multiple drop-down menu items in ASP.NET using AngularJS

I am currently working on a student registration form that includes two drop-down list boxes. The first box contains gender details, and the second one contains subject details. I am attempting to populate these items for the corresponding list boxes in ...

Enhancing input fields in Jquery to track remaining characters for multiple inputs replicated

I am facing an issue with updating a text field where the character count needs to be taken into account. Below is the code snippet: function updateCountdowt() { var remainingt = 30 - jQuery('.account-edit-field').val().length; ...

Tips for invoking C language code from JavaScript by using the js-ctypes extension in Firefox

I need assistance with developing a Firefox extension that requires calling native C code. Here is my C program code: #include<windows.h> int add(int a, int b) { return(a + b); } And here is my JavaScript code: var {Cu} = require('chrome ...