ng-href url not working

574 Views Asked by At

I don't know why ng-href isn't working.
What i want to do is go from a modal to a view, passing the parameters {{user}} and {{email}}

here's the state

//gestion
.state('gestion',
{
url:'/compte/gestion/:user/:email',
templateUrl:'templates/gestion.html',
controller:'loginCtrl'  
})

code from the controller

$scope.goToState = function () {
$state.go('gestion', {user:'$scope.user', email: '$scope.email'});}

$scope.user and $scope.email are two values i retrieve from an external url

and here's the line from the view with the ng-href

<ion-item ng-click="goToState()" style="width:340px;margin-top:10px" >
Gerer mon compte
</ion-item> 

thank you for help

3

There are 3 best solutions below

2
Ram_T On

Instead of ng-href use ng-click. Because ng-href is for anchor tags.

<ion-item ng-click="goToState()" style="width:340px;margin-top:10px" >
Gerer mon compte
</ion-item> 

In your controller, add the function

$scope.goToState = function () {
    $state.go('gestion', {user: 'User', email: '[email protected]'});
}
2
abdoutelb On

Are you using $locationProvider.html5Mode(true); ??

you can use instead ui-sref="gestion({ user: user , email : email })"

0
Rated Ace On

i solved this by accident.i was in a modal.the modal was covering the entire screen.i had closeModal() implemented already but totally forgot to include it in ng-click.totally forgot about it.so the view was there just couldn't see it. anyway thanks for help