【问题标题】:AngularJs - $filter('filter') service does not work properlyAngularJs - $filter('filter') 服务无法正常工作
【发布时间】:2014-07-31 08:20:36
【问题描述】:

我对 Angularjs 中的 $filter 服务有疑问,例如我有一个对象,我想在该对象中搜索:{date: "2014-06-01",LandingPage: "/alimentation-bio-c585"},但问题是如果我这样做 LandingPage: "/a" 它匹配,我希望它搜索不是 Like % 的确切值。

我的对象:

var tab = [{"id": 1,"date": "2014-06-01","LandingPage": "/","Sales": 78},{"id": 1,"date":"2014-06-02","LandingPage": "/alimentation-bio-c585","Sales": 97}];

我的过滤器:

var myRedObjects = $filter('filter')(tab, {date: "2014-06-02",LandingPage: "a"})

它找到了对象,我不希望它找到 exept 如果它:"LandingPage": "/alimentation-bio-c585"

我看到了文档,并为严格模式的比较器参数添加了 true,但它没有用,请帮助我。

【问题讨论】:

    标签: angularjs angular-filters


    【解决方案1】:

    请看这里http://jsbin.com/vayuz/1/edit?html,js,output

    添加'true'作为第三个参数进行严格比较

    $scope.strictmyRedObjects = $filter('filter')
    (tab, {date: "2014-06-02",LandingPage: "a"}, true);
    

    【讨论】:

      猜你喜欢
      • 2021-01-22
      • 1970-01-01
      • 2022-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      相关资源
      最近更新 更多