私は角を使用していますng-table
テスト準備プラットフォームのためのフィルタリング。私はDBに質問ごとに0 or 1
というクイズの結果を保存していますが、ユーザにCorrect
またはIncorrect
と表示する必要があります。フィルタに条件を追加してください
私は{{q.result == 1 ? 'Correct' : 'Incorrect'}}
でこれを行うことができています。しかし、これはまた、フィルタリングに適用する必要があり、意味、ユーザが「正しい」と入力することが可能とq.result = 1
ですべての質問をフィルタする必要があります<tr ng-repeat="q in $data">
<td title="'Correct/Incorrect'" filter="{ result: 'text'}" sortable="'q.result'" ng-class="{correct: q.result == 1, incorrect: q.result == 0}">
{{q.result == 1 ? 'Correct' : 'Incorrect'}}
</td>
filter="{ result: 'text'}
を上記の3慣行に従って変更しようとしましたが、動作しません。
filter="{(result == 1 ? 'Correct' : 'Incorrect') : 'text'}"
はエラーを与える:
Syntax Error: Token '(' invalid key at column 2 of the expression [{(result == 1 ? 'Correct' : 'Incorrect') : 'text'}] starting at [(result == 1 ? 'Correct' : 'Incorrect') : 'text'}].
私はディレクティブを使用しています:args
をConsole.logging
angular
.module('DDE')
.directive('results',['$rootScope', 'NgTableParams', function ($rootScope, NgTableParams) {
return {
restrict: 'AE',
scope: {},
transclude: true,
templateUrl: '/html/directives/results.html',
link: function(scope, elem, attr){
scope.questions = [];
/*
If user took a new test, show results
*/
scope.$on('show-results', function(event, args) {
scope.setData(args);
});
/*
Set question data
*/
scope.setData = function (args) {
console.log(args);
scope.questions = args;
scope.tableParams = new NgTableParams({}, { dataset: args});
};
}
}
}]);
ができます:
コントローラにテーブルを作成する場所を含めることはできますか? –
@AlonEitan上記参照、それは指令です – Growler