V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Ionic
likai
V2EX  ›  Ionic

Ionic+angularjs 传参数问题请教

  •  
  •   likai · 2015-06-25 18:50:17 +08:00 · 5631 次点击
    这是一个创建于 3199 天前的主题,其中的信息可能已经有所发展或是发生改变。
    公司要上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,
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   958 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:15 · PVG 05:15 · LAX 14:15 · JFK 17:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.