在这个例子中,如何重复特定马卡的模型?(How repeat modelos for a specific marca in this example?)
我想重复一下雪佛兰模型。 这是我的代码
<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" }, ]; }])这个例子在这里http://plnkr.co/edit/JmhcU06dypoCwOzszLom?p=preview
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
最满意答案
您需要使用过滤器:
<ul ng-repeat="marca in marcas | filter:'chevrolet'">https://docs.angularjs.org/api/ng/filter/filter
Your need to use a filter:
<ul ng-repeat="marca in marcas | filter:'chevrolet'">https://docs.angularjs.org/api/ng/filter/filter
更多推荐
发布评论