2017-01-01 20 views
1

我在Angular中執行搜索,因此json文件是動態上傳的,我想讓人們可以輸入某些單詞以便根據上傳的json文件進行搜索。 我上傳控制器:角度動態搜索JSON文件中的單詞

app.controller('myController' , function ($scope , $timeout){ 
 
    $scope.beforeIndex = {}; 
 
    $scope.container = {}; 
 
    $scope.set = {}; 
 
    
 
    $scope.searchResults = []; 
 
    $scope.message = { 
 
     status: false, 
 
     message:false 
 
    }; 
 
    $scope.loadFile = function() { 
 
     $timeout(function() { 
 
      $scope.beforeIndex[$scope.file.name] = angular.copy($scope.file); 
 
     } , 200); 
 
    }

上傳的作品做一個動態搜索可以理解successfully.Any指導。

如果你想看看這個角度插件
+0

你試過看看這個? https://github.com/ghiden/angucomplete-alt –

+0

不,我正在通過它馬上。 – Mmoja

+0

我可以看到json在代碼中靜態聲明。我可以使用哪種技術來啓用對json文件的動態加載進行搜索? – Mmoja

回答

0

https://github.com/ghiden/angucomplete-alt 

,也許這樣使用它(從遠程端點retrive數據)

$scope.remote_url = "http://localhoat:3000/api/Artist/Search/?word="; 


<div angucomplete-alt 
          id="artist" 
          placeholder="Search Artist ..." 
          pause="400" 
          selected-object="searchArtist" 
          remote-url="{{ remote_url }}" 
          title-field="nome" 
          remote-url-data-field="data" 
          minlength="1" 
          input-class="form-control form-control-small" 
          match-class="highlight"> 
         </div> 

希望它可以幫助你..並投入正確的方向