使用 $state 时隐藏的参数不起作用 - AngularJS,Ionic

Hidden params when using $state not working - AngularJS, Ionic

我是 ionic 框架的初学者。

我正在尝试将 stateParams 与状态一起使用,但我不希望它在 URL 中公开。

我可以在将 stateParams 添加到 URL (url/:param1) 时使用它,但是当我尝试在 'params' 下声明它时,如此处所述 [ How to send and retrieve parameters using $state.go toParams and $stateParams? ] and here [ AngularJS: Pass an object into a state using ui-router ], 我收到以下错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module surveyApp due to: TypeError: undefined is not a function at getArrayMode (http//localhost:8100/lib/ionic/js/ionic.bundle.js:38251:39) at new Param (http//localhost:8100/lib/ionic/js/ionic.bundle.js:38224:21) at http//localhost:8100/lib/ionic/js/ionic.bundle.js:38857:39 at forEach (http//localhost:8100/lib/ionic/js/ionic.bundle.js:8147:20) at Object.stateBuilder.ownParams (http//localhost:8100/lib/ionic/js/ionic.bundle.js:38856:7) at registerState (http//localhost:8100/lib/ionic/js/ionic.bundle.js:38975:72) at $StateProvider.state (http//localhost:8100/lib/ionic/js/ionic.bundle.js:39460:5) at $StateProvider.IonicModule.factory.config.$stateProvider.state (http//localhost:8100/lib/ionic/js/ionic.bundle.js:45621:31) at http//localhost:8100/js/app.js:88:3 at Object.invoke (http//localhost:8100/lib/ionic/js/ionic.bundle.js:11994:17) http//errors.angularjs.org/1.3.6/$injector/modulerr?p0=surveyApp&p1=TypeEr…3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A11994%3A17)

这是我的代码片段:

.state('tab.mytab', {
    url: '/mytab/:name',
    params: ['item'],
    views: {
        'tab-mytab': {
            templateUrl: 'templates/mytab/item.html',
            controller: 'MyTabCtrl'
        }
    }
})

有什么建议吗?

您使用的参数数组语法很旧,我相信自 0.2.12 起不再受支持

您可以使用

params: { item: null}

对象作为参数而不是数组。 Docs