V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Ionic
likai
V2EX  ›  Ionic

Ionic+angularjs 传参数问题请教

  •  
  •   likai · Jun 25, 2015 · 7877 views
    This topic created in 3961 days ago, the information mentioned may be changed or developed.
    公司要上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,
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3817 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 05:17 · PVG 13:17 · LAX 22:17 · JFK 01:17
    ♥ Do have faith in what you're doing.