Yatin
Yatin

Reputation: 697

window.location.href not working in mobile device in an ionic app

I am trying to open a view with a function call from UI side

<ion-option-button class="button-light icon ion-chatbubble" ng-click="openView('username')"></ion-option-button>

the controller code for the same is

$scope.openView=function(user){
        window.location.href ="/signin.html#/im?p=@"+user;
      };

Now this works perfectly in the browser but when I test this in mobile device I get the following error :-

ERR_FILE_NOT_FOUND(file:///signin.html#im?p=username)

I know there are multiple ways and preferably one should use ui router etc but I have load the view of another angular app inside my app that is why I am somehow stuck on this.

Upvotes: 3

Views: 9291

Answers (2)

Sergey
Sergey

Reputation: 341

path on ionic should be relative, remove leading slash and try:

window.location.href ="signin.html#/im?p=@"+user;

Upvotes: 3

KAUSHAL J. SATHWARA
KAUSHAL J. SATHWARA

Reputation: 994

$scope.openView=function(user){ $state.go('app.signin'); };

and $state defined in your controller.

Upvotes: 0

Related Questions