で$フィルターを注入することができません。私は私のディレクティブ内のコントローラを使用しています。内部フィルタを使用しますが、私は「この$フィルタは関数ではありません。」実行時例外を取得していたコントローラのコンストラクタに:私は、関数(文字列)の変化(searchAttribute)を宣言しました。角度活字体:コントローラ
私は$フィルタサービス同様注入Googleで多くの例を持っているが、私はそれは私のために働いていない理由を把握することができません。
マイコード:
module app.directive {
interface MyDirectiveScope extends ng.IScope {
myModel: any[];
change(searchAttribute: string);
}
class MyController {
static $inject = ['$scope', '$filter'];
constructor(public $scope: MyDirectiveScope, public $filter: ng.IFilterService) {
//code
$scope.change = function (searchAttribute) {
$scope.myModel = this.$filter('filter')($scope.myModel, searchAttribute); //error : this.$filter turns out to be undefined here
};
}
}
class MyDirective implements ng.IDirective {
static instance(): ng.IDirective {
return new MyDirective;
}
restrict = "E";
replace = true;
templateUrl = "myTemplate.html";
controller = MyController;
scope = {};
}
angular.module("myModule")
.directive("myDirective", MyDirective.instance);}