angularjs如何将数组放入我的网址

时间:2017-10-22 01:31:55

标签: ruby-on-rails angularjs ruby

我在我的网址中获得了多个月我的问题我得到的是对象而不是我选择的月份名称

enter image description here

你可以在我的网址中看到我有对象个月=%5Bobject%20Object%5D

我希望看到这个月= [mar,apr]

这是我在该特定组合框中的观点

md-input-container flex=""
      label Months
      md-select ng-model="params.months[month]" multiple="true"
        md-option ng-repeat="month in ctrl.months "  ng-value="month"
          | {{month}}

这是我的控制器

#= require ./../../module

class IncomeStatementIndexCtrl
  constructor: ($scope, $route, $mdDialog, $filter, $routeParams, $location, Account, Branch)->
    @branches = Branch.query()
    @clear = ->
      $scope.params = {}
      $location.search($scope.params)

    $scope.params = $location.search()

    @months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 
    'Sep', 'Oct', 'Nov', 'Dec']

   if $scope.params.as_of_date?
     $scope.params.as_of_date = new Date($scope.params.as_of_date)
     @incomes = Account::IncomeStatement.query ($scope.params), (data) =>


   @search = () =>
     $scope.params.date_to_compare = 
     $filter('date'($scope.params.date_to_compare , "yyyy-MM-dd")
     $scope.params.as_of_date = $filter('date')
    ($scope.params.as_of_date , "yyyy-MM-dd")
     $location.search($scope.params)



IncomeStatementIndexCtrl.$inject = ["$scope", "$route", "$mdDialog", "$filter", "$routeParams", "$location", "Account", "Branch"]

angular
  .module "CaesApp"
  .controller "IncomeStatementIndexCtrl", IncomeStatementIndexCtrl

我需要实现这一点,所以我可以在我的控制器中使用ruby on rails

来更正params

1 个答案:

答案 0 :(得分:1)

我不太了解角度,但对于任何请求的发送数组是:

request =  url?parameter[]=a&parameter[]=b&parameter[]=c

并且在轨道上它是

"parameter":[
"a","b","c"
]