0

I have to open the new tab using state.go with parameter,

State config:

 .state("view", {
    url: "/view",
    templateUrl: 'app/components/view/view.html',
    controller: 'viewController',
    params: {
      data: ''
    }
  })

In the some controller:

var url = $state.href('view', {data: JSON.stringify($scope.data)});

    window.open(url,'_blank');

When i tried above code its redirecting to new tab but i can't able to get the passed params values in the viewcontroller.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • You may find the answer here [State.go to new tab with parameter in angularjs](https://stackoverflow.com/a/51565518/1959948) – Dalorzo Jul 28 '18 at 04:31

1 Answers1

0

In your controller you have to inject $stateParams like

.state("view", {
   url: "/view/:data",
   templateUrl: 'app/components/view/view.html',
   controller: 'viewController'
})

.controller('viewController', ['$stateParams', function($stateParams) {
    $scope.params = $stateParams.data; // here you get parameter values
})