1

I'm having a little trouble with a window.

I have to make a windows.open.so far everything very well and without problems, the detail is that this new window is a login that redirects me when I login and I must capture the new url at that time.

my question is, is it possible to make a variable that listens to this new window? and whenever I detect a change in the url I save the whole url?

the process is

http://localhost:8520/pasar -> http://localhost:8520/login?blahblahblah -> http://finalURLWithParams.com/&hi=123&code=456

after logging in and all I have to do is capture code. Is it possible to do this?

      $scope.rowAuthJSONConnect = function () {
            console.warn("Entrando a rowAuthJSONConnect");
            console.warn("URL:");
            console.log(vm.URLRowAuthJson);

            var windowOpen = window.open('http://localhost:8520/pasar', "RedsysOpen", "width=900,height=600");

            console.log(windowOpen);

        }

1 Answer 1

1

You can make the child window update the URL in parent window by calling a setter method in parent window, like below,

    // define this method in main window (angular controller )
    window.setNewUrl = function(result) {
        console.log("new URL is : " + result);
    }

    //define the function below in the child window (the window that you opened with window.open)

    function sendUrlToParent() {
      try {
            window.opener.setNewUrl("new url here");
      } catch(e) {
            console.log("Exception setting value in parent " + e);
      }
    }

If you want to update any angular variable inside the setNewUrl method, I think you need to call $scope.$apply in the end.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Just what I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.