0
解析URL PARAM我有工作這樣的代碼Angularjs:通過服務器響應
app.ts
function getYear(): number {
const date = new Date();
let year = date.getFullYear();
}
$urlRouterProvider.when("/", `/year/${getYear()}`);
$stateProvider.state("/", {
url: "/"
}).state("app", {
url: "/year/{year:int}",
controller: "AppController as ctrl",
templateUrl: "templates/application.html",
requireADLogin: true,
params: {
year: getYear()
}
})
包子現在它該電源線,以從服務器獲取的 '年' PARAM。
我一直試圖做這樣的事情:
$stateProvider.state("/", {
url: "/"
}).state("app", {
url: "/year/{year:int}",
controller: "AppController as ctrl",
templateUrl: "templates/application.html",
requireADLogin: true,
resolve: {
year: ["YearService", (yearService: services.YearService) => {
return yearService.GetYear();
}]
}
})
但這只是掛在頁面守望例外anormous量。
此外,我在想:
$stateProvider.state("/", {
url: "/"
}).state("app", {
url: "/year/{year:int}",
controller: "AppController as ctrl",
templateUrl: "templates/application.html",
requireADLogin: true,
params: {
year: function(){
//Here is the question
//How to resolve services.YearService?
}
}
})
可以試試你的PARAMS這樣的.. PARAMS:{ 年:{類型:「詮釋」,原料:真正}} HTTPS –
: //ui-router.github.io/ng1/docs/latest/interfaces/params.paramdeclaration.html –