Angularjs 如何使用$stateProvider将参数插入URL?

Angularjs 如何使用$stateProvider将参数插入URL?,angularjs,Angularjs,这是我的密码: $stateProvider .state('game.wordSearch', { url: "/wordSearch/:index/", template: wordSearchTemplate, controller: function($stateParams){ app.wordSearchIndex=$stateParams.index}}) 因此,如果我在URL栏中键入www.m

这是我的密码:

$stateProvider
    .state('game.wordSearch', {
        url: "/wordSearch/:index/",

        template: wordSearchTemplate,

        controller: function($stateParams){

            app.wordSearchIndex=$stateParams.index}})
因此,如果我在URL栏中键入
www.mysite.com/wordSearch/14
,它就会显示索引为14的单词搜索。现在,我必须弄清楚如何从我的网站上的不同视图导航到这一点


在我的网站上,有一堆框,如果你点击其中一个,它会告诉javascript你想要的全局变量wordSearchIndex的游戏。但是如果我导航到应用程序上的页面,我只知道如何将状态更改为
game.wordSearch
。我不知道如何调用此状态并告诉它将
wordSearchIndex
作为
:index
的参数。我如何做到这一点?

您必须做到这一点才能导航:

 $state.go('game.wordSearch', { index: wordSearchIndex});