ionic $state.go() 传参

例子: 

$state.go("tab.home" , {"hello": "world"})

 

重点: 

接受参数的页面--tab.home,需要在配置路由的时候设置参数,如下:

.state('tab.home', {
    url: '/home',
    cache: false,
    views: {
        'tab-home': {
            templateUrl: 'modules/home/partial/home-index/home-index.html',
            controller: 'HomeIndexCtrl'
        }
    },
    //必须带有params,具体要传入的参数在params里面先声明
    params:{
        hello: ""
    }
})

这样,当进入tab.home时,就可以通过,$stateParam.hello来显示出传过来的hello参数了,--> hello: "world"

posted @ 2017-04-25 17:25  FEer_llx  阅读(693)  评论(0编辑  收藏  举报