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 –