angularjs - how I make <a> to show me alone element with a filter? -
this code want filter 'marcas' when click ....
<body ng-controller="marcascontroller"> <a>chevrolet</a> <a>renault</a> <ul ng-repeat="marca in marcas"> <li ng-repeat="tipo in marca.modelo">{{tipo.nombre}}</li> </ul> </body>
---show me alone renault or chevrolet depends click---
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" }, ]; }])
show me alone renault or chevrolet depends click
you use, example
<a ng-click="marcas.selected = 'renault'">renault</a>
and
<ul ng-repeat="marca in marcas | filter:{nombre:marcas.selected}">...</ul>
before posting question on so, should first try create own solution , include attempt(s) in question.
Comments
Post a Comment