在这个例子中,如何重复特定马卡的模型?(How repeat modelos for a specific marca in this example?)

编程入门 行业动态 更新时间:2024-10-15 18:23:08
在这个例子中,如何重复特定马卡的模型?(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

更多推荐

本文发布于:2023-07-07 21:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068433.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在这个   模型   例子   repeat   specific

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!