我有一个打开模态的按钮。
这个模式打开两次(覆盖另一个),我无法弄清楚原因。
也许这是一个非常简单的问题,但我是棱角分明的新人。
我意识到$stateParams
变量使对象获得2次而不是1次。这里是console.log输出:
Object { page: "1", sort: "id,asc", search: null, month: "", ope: "", codeAr: "", reIsus: Array[1] }
Object { page: "1", sort: "id,asc", search: null, month: "2016/12", ope: "", codeAr: "", reIsus: Array[1] }
array[1]
中的项目在两行中都相同
和
.state('validate', {
url: '/validate',
data: {
authorities: ['ROLE_USER']
},
params: {
reIsus: {
array: true
}
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
console.log($stateParams)
if(!$stateParams.reIsus){
$state.go('re-isu', null, { reload: 're-isu' });
}
else{
$uibModal.open({
templateUrl: 'app/entities/re-isu/re-isu-validate-dialog.html',
controller: 'ReIsuValidateController',
controllerAs: 'vm',
backdrop: 'static',
size: 'lg',
resolve: {
reIsusToValidate: function() {
var tabIds = [];
$stateParams.reIsus.forEach(function(ri) {
if (ri.selected === true) {
tabIds.push(ri);
}
});
return tabIds;
}
}
}).result.then(function() {
$state.go('re-isu', null, { reload: 're-isu' });
}, function() {
$state.go('^');
});
}
}]
})
我的主视图用按钮打开模态:
<tr ng-repeat="reIsu in vm.reIsus track by reIsu.id"><td><button type="submit" ng-click="vm.unitaryValidation(reIsu)"
class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-ok"></span>
<span class="hidden-xs hidden-sm" data-translate="entity.action.validate"></span>
</button>