【问题标题】:Using Angular Typeahead on Nested Objects在嵌套对象上使用 Angular Typeahead
【发布时间】:2015-10-22 01:50:40
【问题描述】:

我正在尝试在嵌套对象数组上使用 Angular Bootstrap Typeahead,但我不知道如何写出预先输入。

我的数组中的对象是这样的:

{
  "category": "Locations",
  "regions": [
    {
      "name": "Northeast",
      "category": "region",
      "states": [
        {
          "name": "New York",
          "category": "state"
          "cities": [
            {
              "name": "Syracuse",
              "category": "city"
            }
          ]
        }
      ]
    } 

我只想返回名称值。那么我将如何写出来呢? 我目前正在写<input ... typeahead=" filter.name for filter in filters| filter:$viewValue | limitTo:5">

【问题讨论】:

    标签: angularjs angular-ui-bootstrap angular-ui-typeahead


    【解决方案1】:

    而不是使用“in filters”,只需执行“in transformFilters()”之类的操作

      $scope.transformFilters = function () {
          // Loop over filters and create an array of
              {name: name, category:cat}
    
         return my new array
    
      }
    

    【讨论】:

      猜你喜欢
      • 2014-08-24
      • 2021-03-28
      • 1970-01-01
      • 1970-01-01
      • 2019-05-28
      • 2023-03-13
      • 2017-10-03
      • 2018-07-31
      • 2021-02-05
      相关资源
      最近更新 更多