2017-06-20 171 views
0

我不知道为什么ng-href无法正常工作。
我想要做的是从modalview,传递参数{{user}}{{email}}ng-href url not working

这里的状态从控制器

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

$范围

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

代码。用户和$ scope.email是我从外部URL检索到的两个值

,这里是从view行与ng-href

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

谢谢大家帮忙

回答

2

代替ng-href使用ng-click。因为ng-href用于定位标记。

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

在你的控制器中添加

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

我试过你的解决方案。当我点击该项目,其他视图不出现。没有错误或警告。= –

+0

只要确保你传递的有效参数在$状态。去()'。我只是提到样本。让我看看你的代码(更新你的代码) –

0

是否使用$locationProvider.html5Mode(true);的功能?

您可以通过accident.i改用ui-sref="gestion({ user: user , email : email })"

+0

我不知道什么是$ locationProvider和你的解决方案,如果我改变ng-href,我也需要改变状态url? –

+0

@RatedAce如果您不使用第一行,请不要担心。你可以不加改变地使用'ui-sref'。如果不工作,你可以坚持@Mr_Perfect'ng-click' – abdoutelb

0

我解决了,这是在modal.the模式是覆盖整个screen.i有closeModal()来实现,但已经完全忘把它列入NG-点击完全忘了它,所以那里的看法就是看不到它。 无论如何感谢您的帮助