0
在位置表中添加数据后,单击保存按钮应将其重定向到位置表中的数据列表。但是,它在添加后保持在同一页中。给出相同的路径来修改位置,它工作正常。而添加位置时相同的路径不会重定向。angularjs中的重定向错误
function locationController($scope, $state, $rootScope, locationServices,$location, locations, location, primaryLocation, $stateParams,locationTypes, countries) {
var vm = this;
$scope.locations = locations.data;
$scope.location = location.data;
if (primaryLocation.data && primaryLocation.data[0])
$scope.primaryLocation = primaryLocation.data[0];
if (!$scope.location) {
var location = {};
if ($stateParams.accountId) {
$scope.location = {accountId: $stateParams.accountId };
} else {
$scope.location = location;
}
}
$rootScope.title = "Locations";
$scope.locationslist = "views/locations.html";
$scope.addOrModifyLocation = function (location) {
if (location._id) {
locationServices.modifyLocation(location).then(function (response) {
$location.path('/account/locations/contacts/' + location.accountId + '/' +location.accountId);
// $state.reload();
})
} else {
location.status = 'ACTIVE';
locationServices.addLocation(location).then(function (response) {
$location.path('/account/locations/contacts/' + location.accountId + '/' +location.accountId);
})
}
};
感谢您的答案。我正在使用ui-router。我已经尝试了您的建议,但仍然没有重定向到指定的路径。 – Sarah
我通过添加调试路由期间发生的错误的方式更新了我的答案。 你也可以通过添加你声明你想要去的状态来更新你的问题吗? –