ngFilter等于2 var的角度

时间:2017-06-22 19:43:34

标签: javascript angularjs angularjs-ng-repeat ng-filter

我有一点问题,我想在ngFilter中使用2 var等于。我尝试了很多组合,但它不起作用......

我在$ routeParams

中获得了第一个var
function ANNAnnonceListe(DBManager, $routeParams) {
var ici = this;
this.annonces_ar = [];
this.idLieu = $routeParams.idLieu;

DBManager.all('ANNAnnonce')
    .then(function (annonces) {
        console.log(annonces);
        ici.annonces_ar = annonces;
    })
    .catch(function (error) {
        console.log(error)
    });
}

第二个在这里:

<div ng-repeat="(key, value) in vm.annonces_ar | filter: {value.id : vm.idLieu_nb} ">
    {{value.nom_str}}
    {{value.idLieu_nb}}
</div>

我想要这个相等(vm.idLieu = value.id_nb)并显示if是否为

感谢。

1 个答案:

答案 0 :(得分:1)

它应该是属性名称id_nb而不是value.id。在过滤器的末尾也有: true参数来执行精确检查,尽管包含检查。

<div ng-repeat="(key, value) in vm.annonces_ar | filter: { idLieu_nb : vm.idLieu}: true ">
    {{value.nom_str}}
    {{value.idLieu_nb}}
</div>