直接在URL中更新参数值时,AngualrJS路由不起作用

时间:2018-10-31 01:44:57

标签: angularjs angular-ui-router

以下是我的网址

{ "_originalElementInner": " <input type=\"file\" name=\"\" class=\"hidden\" id=\"file_input_two\" onchange=\"alertFilename(this.value,'cropped_two');\"> <!-- <img src=\"https://dxyz.com/tmp/5bd432ed2d8dd_img3.jpg\" alt=\"\" width=\"100%\" height=\"100%\"> --> " }

如果我将localhost:9000/index.html#!/app/apis/1066/general的值更改为1067,则应该基于1067更新param的常规信息。 但是,API(s)会立即设置回URL值1066,并且页面不会刷新。 这是我的路线:

param

如有需要,我可以提供更多信息。我正在使用angularjs 1.7

2 个答案:

答案 0 :(得分:0)

这可能是因为状态提供程序不在其缓存键中考虑新的URL道具。 尝试在状态上禁用缓存,看看是否有帮助

.state('app.apis', {
    cache: false,
    url: "/apis/:id",
    templateUrl:"views/dashboard/apisMain/updateApis.html",
    controller: "updateApisCtrl",
    resolve:{
        apiData :function ($stateParams,  proxyService) {
            return proxyService.api($stateParams.id);
        }
    }

答案 1 :(得分:0)

您在常规路径配置状态下缺少参数ID,请尝试更改它:

state('app.apis.general', {
            url: "/general",
            templateUrl: "views/dashboard/general/updateGeneral.html",
            controller: "updateGeneralCtrl"
        })

>>>change  

state('app.apis.general', {
            url: "/:id/general",
            templateUrl: "views/dashboard/general/updateGeneral.html",
            controller: "updateGeneralCtrl"
        })