0

I'm using angularjs, Below is my code and I need output as

red

green

yellow

It is displaying as an array

['red','green','yellow']

Please help.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> 
</script>

<body ng-app="myApp" ng-controller="myCtrl">

    <div ng-repeat="product in products | filter: { color: true }">
       {{product.type}}
     </div>
</body>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
      $scope.products = [
   { id: 1, name: 'test', color: true, type:['red','green','yellow'] },
   { id: 2, name: 'bob', color: false },
   { id: 3, name: 'john', color: false },
   { id: 4, name: 'rock', color: false },
   { id: 5, name: 'mercy', color: false },
   { id: 6, name: 'jack', color: false }
  ];
});

Please help

0

1 Answer 1

6

**Thanks i got answer, if any good alternative. please share **

<div ng-repeat="product in products | filter: { color: true }">

     <div ng-repeat ="type in product.type">
     {{type}}
      </div>


</div>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.