basil basil - 1 month ago 4x
Javascript Question

drop down filter not working in angularjs

I am trying to develop angularjs filter but I can't get result in the code below to show only one scope filter. How can I fix it? How to filter using drop down box value . it filter two type like select box filter and text box value filter

<html >
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<div ng-app="app" ng-controller="mainCtrl">
<div>Search by Name: <input type="text" ng-model=""></div>

<select ng-model="selectedCompany" >
<option ng-repeat="xi in array" value="{{}}">{{}}</option>


<div ng-repeat="arr in array | | filter:{company:}">
<span ng-bind=""></span>
<h1>You selected: {{selectedCompany}}</h1>

<script type="text/javascript" src="js/angular.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.9.0.js"></script>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('mainCtrl', function($scope) {

$scope.filters = {
x: false,
company: '',
search: ''

$scope.actions = {
updateyCompany: function () {
if($scope.filters.y) {
$ = 'y';
} else {
$ = '';

$scope.array = [
{name: 'Tobias', lname: 'TLname', company: 'x'},
{name: 'Jeff', lname: 'JLname', company: 'x'},
{name: 'Brian', lname: 'BLname', company: 'x'},
{name: 'Igor', lname: 'ILname', company: 'y'},
{name: 'James', lname: 'JLname', company: 'z'},
{name: 'Brad', lname: 'BLname', company: 'y'}


Thank you @basil


Just make below change and it should work (you have bind your select to "selectedCompany" so will have to use that in your filter as well):

 <div ng-repeat="arr in array | | filter:{company: selectedCompany}">
           <span ng-bind=""></span>