目前我们的项目使用默认$routeProvider,我正在使用这个"hack",url无需重新加载页面即可进行更改:
services.service('$locationEx', ['$location', '$route', '$rootScope', function($location, $route, $rootScope) {
    $location.skipReload = function () {
        var lastRoute = $route.current;
        var un = $rootScope.$on('$locationChangeSuccess', function () {
            $route.current = lastRoute;
            un();
        });
        return $location;
    };
    return $location;
}]);
并在 controller
$locationEx.skipReload().path("/category/" + $scope.model.id).replace();
我想到的替换routeProvider用ui-router筑巢路线,但无法找到这ui-router.
是否有可能 - 做同样的事情angular-ui-router?
我为什么需要这个?让我用一个例子说明:
用于创建新类是路线/category/new
后clicking在SAVE我秀success-alert,我想改变路线/category/new,以/caterogy/23(23 -是存储在数据库新项目的ID)
我是Angular和ui-router的新手.当有人选择模型并且我的控制器执行标准的SHOW方法时,我只想更新URL以包含模型的ID而不刷新页面,并继续我的原始视图.我不知道怎么做...
$stateProvider
        .state('citylist', {
          url: "/",
          templateUrl: "views/index.html"
        })
        .state('cityshow', {
          url: "/city/:id",
          templateUrl: "views/index.html"
        })
angular.module('app.system').controller('IndexController', ['$scope', 'Global', 'Cities', '$stateParams', '$location', function ($scope, Cities, $stateParams, $location) {
    $scope.loadTown = function(id) {
        Cities.get({id: id }, function(city) {
             $scope.city = city
             // Change URL
             // Do things within the same view...
        });
    };
});
<button ng-click="loadTown(123456)">Chicago</button>