按选择值进行过滤不起作用

时间:2017-06-29 10:58:43

标签: angularjs

无法将选定的值添加到angularjs中的过滤器中获取此错误(错误:意外的令牌。)

内部控制器

$scope.search_type_options=[{name:"Name",value:"name"},{name:"Id",value:"id"},{name:"Update By",value:"updated_by"}];

$scope.search_val = function()
{
   $scope.fs={$scope.search_type.value:$scope.search_txt};
   $scope.filter_dt=$filter('filter')($scope.temp_data,$scope.fs);
}

我需要输出     {name:" raj"}

内部模板

<div class="form-group">
  <select name="search_type"  ng-model="search_type" ng-options="item as item.name for item in search_type_options">
  <option value="">--select search type</option>
  </select>
</div>
<div class="form-group">
  <input type="text" ng-model="search_txt" class="form-control" placeholder="Search">
</div>
  <button type="submit" ng-model="search_btn" ng-click="search_val()"class="btn btn-default">Go</button>
</div>

1 个答案:

答案 0 :(得分:0)

不确定这是否是正确的js语法

$scope.fs = {}; $scope.fs[$scope.search_type.value] = $scope.search_txt;

通常它应该像这样写

deploy:
  stage: deploy
  script:
    - ./deploy.sh
  only:
    - master