Angularjs 正在$state.go中传递作用域
我一直在研究应用程序中的路由。我有一些数据可以处理,但最后我需要有人点击按钮,然后转到某个链接。此链接信息存储在$scope.stories.link中 $scope.stories.link=beautyanthebeast.htmlAngularjs 正在$state.go中传递作用域,angularjs,ionic-framework,Angularjs,Ionic Framework,我一直在研究应用程序中的路由。我有一些数据可以处理,但最后我需要有人点击按钮,然后转到某个链接。此链接信息存储在$scope.stories.link中 $scope.stories.link=beautyanthebeast.html <div ng-repeat="stories in lowage"> <ion-list class="ion-list"> <ion-item href="#/app/{{stories.link}}" >
<div ng-repeat="stories in lowage">
<ion-list class="ion-list">
<ion-item href="#/app/{{stories.link}}" >
{{stories.title}}
</ion-item>
</div>
{{stories.title}
遗憾的是,这不起作用。有人知道如何实现这一点吗?我不确定,但我认为问题在于变量没有插入到代码中。您的程序正在尝试转到#/app/{{stories.link},因为它只是将其视为字符串。您必须使用。我不确定,但我认为问题在于变量没有插入到代码中。您的程序正在尝试转到#/app/{{stories.link},因为它只是将其视为字符串。您必须使用。您可以尝试使用此解决方案,它可能适合您
在Html页面中,将代码更新为
<ion-list ng-repeat="stories in lowage">
<ion-item ng-click="changeRoute(stories)">
{{stories.title}}
</ion-item>
</ion-list>
$scope.changeRoute = function(stories){
$location.url('app/'+stories.link);
}
不要忘记将$location作为依赖项注入
或
您也可以使用这种方式
<ion-list ng-repeat="stories in lowage">
<ion-item ng-href='app/{{stores.link}}'>
{{stories.title}}
</ion-item>
</ion-list>
{{stories.title}
您可以尝试使用此解决方案,它可能适合您在Html页面中,将代码更新为
<ion-list ng-repeat="stories in lowage">
<ion-item ng-click="changeRoute(stories)">
{{stories.title}}
</ion-item>
</ion-list>
$scope.changeRoute = function(stories){
$location.url('app/'+stories.link);
}
不要忘记将$location作为依赖项注入
或
您也可以使用这种方式
<ion-list ng-repeat="stories in lowage">
<ion-item ng-href='app/{{stores.link}}'>
{{stories.title}}
</ion-item>
</ion-list>
{{stories.title}
链接或ng repeat部分有什么不起作用?请详细说明您的问题,我很抱歉。的确,Href='#/app/{{stories.link}}}'不起作用。ng repeat有效,但可点击链接无效。它不想接受{{stories.link}好吧,那么为什么每个故事都需要一个静态html页面呢?故事页面是在你的应用程序中还是外部链接?您需要的是一个带有参数的状态。您可以通过链接传递参数,并根据下一个状态获取故事<代码>https://github.com/angular-ui/ui-router/wiki/URL-Routing这确实是下一步。现在我有点困惑。我正在慢慢地建立它。目前,这些故事是服务器上的html文件。但我现在也通过$http.get将它们交付给我。这包括文本。现在,我将研究传递参数。链接或ng重复部分有什么不起作用?请您详细说明您的问题,我很抱歉。的确,Href='#/app/{{stories.link}}}'不起作用。ng repeat有效,但可点击链接无效。它不想接受{{stories.link}好吧,那么为什么每个故事都需要一个静态html页面呢?故事页面是在你的应用程序中还是外部链接?您需要的是一个带有参数的状态。您可以通过链接传递参数,并根据下一个状态获取故事<代码>https://github.com/angular-ui/ui-router/wiki/URL-Routing这确实是下一步。现在我有点困惑。我正在慢慢地建立它。目前,这些故事是服务器上的html文件。但我现在也通过$http.get将它们交付给我。这包括文本。现在我将研究传递参数。感谢您详细的回答。非常感谢:)谢谢你热情的回复,你能接受我的回答吗谢谢你详细的回复。非常感谢:)谢谢你的热情回复,你能接受我的回答吗