$stateProvider.state('academicYearCatalogue', {
url: '/academicYearCatalogue/:programKey',
templateUrl: 'app-ace/academicYearCatalogue/views/academicYearCatalogue-detail.tpl.html',
controller: 'AcademicYearCatalogueDetailCtrl as AcademicYearCatalogueDetailCtrlVM',
resolve: {
academicYearList: ['AcademicYearService', '$stateParams',
function (AcademicYearService, $stateParams) {
var obj = {
programKey: $stateParams.programKey,
}
return AcademicYearService.getAllYear(obj)
.$promise.then(function (result) {
return result.data;
});
}]
}
});
我想通过ui-router v 0.2.8在控制器之间传递数据,但又不想添加到url,我该如何实现呢?
该programkey来自某个控制器,我想在解析中使用它,但不与url一起使用。我如何实现此目的。
角度js版本为1.2.20
答案 0 :(得分:0)
使用状态的 params 属性,您可以按以下方式传递数据
参数:{ user_desisred_params_name:空, }
因此,下面提供了完整的代码-
$ stateProvider.state('academicYearCatalogue',
{url:'/ academicYearCatalogue',
templateUrl:“ app-ace / academicYearCatalogue / views / academicYearCatalogue-detail.tpl.html”,
控制器:“ AcademicYearCatalogueDetailCtrl as AcademicYearCatalogueDetailCtrlVM”,
解决:{
academicYearList: ['AcademicYearService', '$stateParams',
function (AcademicYearService, $stateParams) {
var obj = {
programKey: $stateParams.programKey,
}
return AcademicYearService.getAllYear(obj)
.$promise.then(function (result) {
return result.data;
});
}]
},
参数:{ yourKey:程序密钥 }
});