我的角度应用程序有一个控制器,可以在模态模式和非模态模式下使用。我想检查它是哪种模式。有人能帮我吗 ?
订单控制器
positions = [centroid - (r/2), r + zeros(size(centroid))];
for k = 1:size(positions, 1)
rectangle('Position', positions(k,:), 'Curvature', [1 1], 'FaceColor', 'r');
end
客户端控制器
$scope.chooseClient = function() {
$uibModal.open({
templateUrl: 'partials/client/edit.html',
controller: 'ClientEditController',
}).result.then(function (client) {
// Modal OK
if (client) {
$scope.model.client = client;
}
}, function (status) {
// Modal cancelado
});
};
答案 0 :(得分:0)
您可以传递带有标志的resolve
对象。这将迫使您在路径中为控制器传递相同的解决方案,并注入以解析控制器。
$scope.chooseClient = function() {
$uibModal.open({
templateUrl: 'partials/client/edit.html',
controller: 'ClientEditController',
resolve: {
isModal: true
}
}).result.then(function (client) {
// Modal OK
if (client) {
$scope.model.client = client;
}
}, function (status) {
// Modal cancelado
});
};
而不是检查:
.controller('ClientEditController', function ($scope, $location, isModal) {
$scope.cancel = function() {
if (isModal) {
$scope.$dismiss('cancel');
} else {
$location.path("/client/list");
}
};
});
请参阅文档:$uibModal