我在使用角度时遇到了设计问题 . 需要建议 .

我有一个基于路线加载的页面 . 现在在页面上我有一些控制数据的过滤器,如价格范围和日期 . 这些过滤器将在url中设置查询参数 . 所以状态查询参数将决定数据 . 并且在过滤器的每次更改时,这些查询参数都应该更改,因此应该加载页面 . 每个过滤器都有自己的指令 .

现在问题是我第一次路由到州 . 这些过滤器是第一次由指令生成的:

  • 我将如何将它们绑定到url查询参数 . 然后将这些查询参数传递给routeProvider,然后传递给将获取数据的控制器 .

  • 当加载页面时我将如何绑定这些过滤器,以便在更改时再次更改查询参数并获取新数据并填充页面 .

  • 如何以双向方向绑定这些查询参数 .

我的代码片段: -

路线: -

decorpot.config(['$routeProvider', '$provide', function($routeProvider, $provide){

    $provide.decorator('ngViewDirective', function($delegate) {
         var directive = $delegate[0];
         directive.replace = true;

         return $delegate;
     });

    $routeProvider.when('/', {
        templateUrl: 'resources/partials/home.html',
        controller: 'DecorpotCtrl'
    }).when('/imageListSpace/:param', {
        templateUrl: 'resources/partials/imageList.html',
        controller: 'ImageListController'
    })
    .otherwise({
        redirectTo: '/'
    });
 }]);

控制器 -

decorpotCtrls.controller('ImageListController', [ '$scope', '$routeParams', 'interiors', function($scope, $routeParams, interiors ) {

    interiors.getImages($routeParams.param).success(function(data) {
        $scope.imageList = data;
    });

} ]);

过滤指令 -

decortDirectives.directive("priceRange", function() {
    $("#priceRange").ionRangeSlider({
        type : "double",
        min : 100000,
        max : 300000,
        prefix : "Rs.",
        prettify_enabled: true,
    });
 });