Javascript AngularJS扩展routeprovider参数并为任何路由调用函数

Javascript AngularJS扩展routeprovider参数并为任何路由调用函数,javascript,angularjs,Javascript,Angularjs,我想扩展routeProvider并实现附加参数(如templateUrl)。然后,每次触发任何路由时,我都希望从routeProvider调用一个作用域位于附加参数上的函数 $routeProvider .when("/Index", { templateUrl:"./Views/index.html", controller:"IndexCtrl", myParam: "./Content/Text/file.json" }) .always(function (my

我想扩展
routeProvider
并实现附加参数(如
templateUrl
)。然后,每次触发任何路由时,我都希望从
routeProvider
调用一个作用域位于附加参数上的函数

$routeProvider
.when("/Index",
{
    templateUrl:"./Views/index.html",
    controller:"IndexCtrl",
    myParam: "./Content/Text/file.json"
})
.always(function (myParam) 
{
    do something for any view with myParam parameter...
}

这个问题背后的背景是。我将非常感谢您的帮助。

您可能需要使用routeProvider的
解析
功能。订阅
$routeChangeStart
$routeChangeSuccess
事件,您将能够从参数中获取当前路由并访问
路由。
路由.scope