0

I want to repeat just of chevrolet modelos for example. this is my code

<body ng-controller="marcasController">
  <ul ng-repeat="marca in marcas">
    <li ng-repeat="tipo in marca.modelo">{{tipo.nombre}}</li>
  </ul>
</body>

var app = angular.module('App', []);

app.controller('marcasController', ['$scope', function($scope) {

$scope.marcas =[

    {
      "nombre": "Chevrolet",
      "image": "images/aveo.jpg",
      "modelo": [
        {"nombre":"aveo", "color":"black"},
        {"nombre":"corsa", "color":"yellow"}
        ],
      "tab": "aveo"
    },
    {
      "nombre": "Renault",
      "image": "images/aveo.jpg",
      "modelo": [
        {"nombre":"clio", "color":"black"},
        {"nombre":"sandero", "color":"red"}
        ],
      "tab": "aveo"
    },
  ];


  }])

This expample here http://plnkr.co/edit/JmhcU06dypoCwOzszLom?p=preview

Gerard
  • 11
  • 1
  • 2

2 Answers2

0

Your need to use a filter:

 <ul ng-repeat="marca in marcas | filter:'chevrolet'">

https://docs.angularjs.org/api/ng/filter/filter

Ezequiel
  • 3,477
  • 1
  • 20
  • 28
0

You can make another model in your $scope and use it to filter the marcas selected

  1. app.js - add the following line

    $scope.selectedModel = "Chevrolet";

  2. Change the ng-repeat in index.html to

    <ul ng-repeat="marca in marcas | filter: selectedModel">

This way you can use the new model $scope.selectedModel by setting it through some user input if you want. It won't be hard coded in the view.