2015-09-25 54 views
1

我有一張我希望能夠搜索的表格。它對測驗題目很好,但課程名稱似乎不起作用。我知道這是因爲課程標題是在另一個字典裏,因爲如果我把「course」而不是「course.title」放在另一個字典中,它會起作用,但它在整個課程對象內搜索,而不僅僅是標題,我不想要它。我怎樣才能搜索只有course.title?我認爲這只是一個語法問題,但我無法在任何地方找到類似的問題。通過AngularJS智能表中的對象內部的對象進行搜索

<table st-table="displayedQuizzes" st-safe-src="quizzes" class="table table-striped"> 
    <thead> 
     <tr> 
      <th st-sort="quiz.title">Name</th> 
      <th st-sort="quiz.course.title">Course</th> 
     </tr> 
     <tr> 
      <th><input st-search="'title'" class="input-sm form-control" placeholder="Search ..." type="search"/></th> 
      <th><input st-search="'course.title'" class="input-sm form-control" placeholder="Search ..." type="search"/></th>   
     </tr> 
    </thead> 
    <tbody> 
     <tr ng-repeat="quiz in displayedQuizzes"> 
      <td>{{quiz.title}}</td> 
      <td>{{quiz.course.title}}</td>   
     </tr> 
    </tbody> 
</table> 

這是我的角度代碼:

angular.module('App') 
.controller('ArchiveCtrl', ['$scope', '$window', 'Archive, function ($scope, $window, Archive) { 
    $scope.quizzes = Archive.query(); 
}]); 
+0

你能告訴角碼? – Gericke

+0

我剛添加它 – arfasvin

+0

控制器聲明中有一個錯誤'.controller('ArchiveCtrl',['$ scope','Archive,function($ scope,$ window,Archive){' - 你沒有定義' $ window'作爲輸入參數 – Michael

回答

0

你確定你必須用引號括了st-search價值?智能表格文檔不使用引號。

http://lorenzofox3.github.io/smart-table-website/

 <input st-search="firstName" placeholder="search for firstname" class="input-sm form-control" type="search"/> 
+0

如果我不這樣做,測驗標題和course.title都不起作用,但我已經嘗試了所有可能的引號組合,但似乎沒有任何東西可以用於這門課程。 – arfasvin

+0

爲了支持你,請提供一個正在運行的運動員。 – Michael