How to filter JSON-Data with AngularJs?

前端 未结 2 603
予麋鹿
予麋鹿 2020-12-04 18:12

I have an array (_users) that contains JSON objects.

{ 
  \"User\":
  {
    \"userid\":\"19571\",
    \"status\":\"7\",
    \"active\":\"1\",
    \"lastlogin         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 19:03

    Since your object model is kind of complex I would recommend using custom filtering function:

    $scope.isActive = function(user) {
        return user.User.Stats[0].active === "1";
    };
    

    and then in your HTML:

    {{user.User.userid}}

    Here is the working jsFiddle: http://jsfiddle.net/pkozlowski_opensource/4kzzy/3/

    Be sure to check angular's documentation on filters if you need more info: http://docs.angularjs.org/api/ng.filter:filter

提交回复
热议问题