0

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

Rated Ace
  • 31
  • 7

3 Answers3

2

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: 'example@gmail.com'});
}
Mr_Perfect
  • 8,254
  • 11
  • 35
  • 62
  • i tried your solution.when i click on the item,the other view doesn't appear.no errors or warnings.= – Rated Ace Jun 20 '17 at 12:29
  • Just make sure that you are passing the valid parameters in `$state.go()`. I jsut mentioned sample. Show me your code(update your code in the question) – Mr_Perfect Jun 20 '17 at 12:32
0

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

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

abdoutelb
  • 1,015
  • 1
  • 15
  • 33
  • i don't know what's $locationProvider is and your solution if i change the ng-href,i would need to change the state url too? – Rated Ace Jun 20 '17 at 12:30
  • @RatedAce if you are not using the first line don't worry about it. You can use `ui-sref` with no change. if not working you can stick with @Mr_Perfect `ng-click` – abdoutelb Jun 20 '17 at 12:33
0

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

Rated Ace
  • 31
  • 7