Ionic+angularjs 传参数问题请教

2015-06-25 18:50:17 +08:00
 likai
公司要上APP。让我这个菜鸟来用Ionic+angularjs

现在要从首页文章列表页传参数到第二个页面。第二个页面根据首页传过来的文章ID参数查询数据库并显示文章内容,
配置:
$urlRouterProvider.otherwise("/news/0");
.state('news', {
url: "/news/:id",
templateUrl: "templates/news.html",
controller: 'NewsController'
})
.state('shownews', {
url: "/news/show/:id",
templateUrl: "templates/news-show.html",
controller: 'NewsController'
})
factory.NewsSrv下:
show = function (id) {
return ApiSrv.req("news.public.News.itemit", {id: id});//从远程取数据
}

angular.module.controller下

$scope.newsshow = NewsSrv.show($stateParams.id);

用a href从news页面传ID进shownews。
现在的问题是。NewsController怎么才能在传参数进入这个页面才开始?

现在我的是一加载第一个页面。请求了两次。第一次请求列表。第二次执行了$scope.newsshow,
5676 次点击
所在节点    Ionic
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/201169

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX