My state. js is like this
我的状态。 js是这样的
.state('lab.new-equip', {
parent: 'lab',
url: '/{labId}/new-equipment',
data: {
authorities: ['ROLE_USER']
},
onEnter: ['$stateParams', '$state', '$uibModal', function ($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'app/entities/lab/lab-equipments-dialog.html',
controller: 'LabEquipmentsDialogController',
controllerAs: 'vm',
backdrop: 'static',
size: 'lg',
resolve: {
entity: function () {
return {
roomId: $stateParams.labId,
equipementName: null,
specification: null,
manufacturer: null,
quantity: null,
author: null,
id: null
}.$promise;
}
}
}).result.then(function () {
$state.go('lab', null, {reload: true});
}, function () {
$state.go('lab');
});
}]
})
I have got the value of the labId using ui-router as below
我已经使用ui-router得到了labId的值,如下所示
ui-sref="lab.new-equip({labId:vm.lab.labId})"
Now I am trying to pass this labId to the view as the value of roomId. Hence i have tried sending with the help of $stateParams.
But i couldn't get the value populated in my modal.
If i change that roomId to an Integer like 2 or 3, it is populating in the modal. But not the previous way.
现在我试图将此labId作为roomId的值传递给视图。因此我尝试在$ stateParams的帮助下发送。但我无法在我的模态中获得填充值。如果我将roomId更改为2或3之类的整数,则会填充模态。但不是以前的方式。
How can i achieve this?
我怎样才能做到这一点?
Is there any other way to accomplish this.
有没有其他方法来实现这一目标。
Thanks in advance
提前致谢
2 个解决方案
#1
0
Try with the following code:
尝试使用以下代码:
function ($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'app/entities/lab/lab-equipments-dialog.html',
backdrop: 'static',
size: 'lg',
resolve: {
selectedRow: function () {
return row.entity.labId;
}
},
controller: function ($scope, $uibModal, selectedRow) {
$scope.selectedRow = selectedRow;
$stateParams.labId = $scope.labId;
}
}).result.then(function () {
$state.go('lab', null, {reload: true});
}, function () {
$state.go('lab');
});
#2
0
Just add like the following
只需添加以下内容即可
resolve: {
entity: function () {
return {
roomId: null,
equipementName: null,
specification: null,
manufacturer: null,
quantity: null,
author: null,
id: null
}.$promise;
}
roomId: function (){
return $stateParams.id;
}
and inject the roomId in the controller to use it in your html page.
并在控制器中注入roomId以在您的html页面中使用它。
#1
0
Try with the following code:
尝试使用以下代码:
function ($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'app/entities/lab/lab-equipments-dialog.html',
backdrop: 'static',
size: 'lg',
resolve: {
selectedRow: function () {
return row.entity.labId;
}
},
controller: function ($scope, $uibModal, selectedRow) {
$scope.selectedRow = selectedRow;
$stateParams.labId = $scope.labId;
}
}).result.then(function () {
$state.go('lab', null, {reload: true});
}, function () {
$state.go('lab');
});
#2
0
Just add like the following
只需添加以下内容即可
resolve: {
entity: function () {
return {
roomId: null,
equipementName: null,
specification: null,
manufacturer: null,
quantity: null,
author: null,
id: null
}.$promise;
}
roomId: function (){
return $stateParams.id;
}
and inject the roomId in the controller to use it in your html page.
并在控制器中注入roomId以在您的html页面中使用它。