0

I have a page in my AngularJS that has an edit button, I need to open the edit page on another tab when I click the edit button. Can it be possible using the angular way? I need to use the same controller to be able to access the data. How can I possible do this? Can someone please give me a sample?

2

1 Answer 1

1

Here's a fiddle to show opening the tab:

https://jsfiddle.net/e8g1m0xs/

I.e.:

angular.module('new_tab', [])
  .controller('ExampleController', ['$scope', '$window', function($scope, $window) {
    $scope.openTab = function() {
      $window.open('https://www.google.com', '_blank');
    };
  }]);

<div ng-app="new_tab" ng-controller="ExampleController">
  <button ng-click="openTab()">New Tab</button>
</div>

But in order to use the same controller for the new tab, and do something like pass information to it, you would have to implement a wildcard pattern into your angular router to pass along state information. I usually do things like that using UI Router. See the section titled URL Parameters.

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

Comments

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.