Sampath
Sampath

Reputation: 65880

Combine $window and $stateProvider to open a new browser tab window

app.js

 $stateProvider.state('tenant.propertyGoogleMap', {
            url: '/PropertyGoogleMap',
            templateUrl: '~/App/tenant/views/propertymanagement/propertyGoogleMap.cshtml',
            menu: 'PropertyGoogleMap.Tenant'
        });

html

<button type="button" class="btn btn-primary" ng-click="vm.propertyGoogleMap()">
                    @L("PfMap")
                </button>

js

 vm.propertyGoogleMap = function () {
                $window.open('tenant.propertyGoogleMap', '_blank');
            };

Could you tell me how to combine both $window and $stateProvider to open a new browser tab when user clicks the button ? When I try as shown above then it gives 404 error.Thanks.

Upvotes: 0

Views: 174

Answers (1)

Andrea
Andrea

Reputation: 3440

try with:

vm.propertyGoogleMap = function () {
                    var url = $state.href('tenant.propertyGoogleMap', {}, {absolute: true});
                    $window.open(url, '_blank');
                };

Where $state is the uiRouter $state service.

The method href with option absoulte: true returns the absolute URL of the given state.

Upvotes: 1

Related Questions