0

I am working a piece of code in angular 1.x , where I would like to filter array of key,values.

HTML:

<input type="text" ng-model="cust"> 

<div ng-repeat="customer in customers| filter :cust['name']">
    {{customer["name"]}}
</div>

JS:

$scope.customers = [
    {"name":"Sathish"},
    {"name":"Ankur"},
    {"name":"Bob"},
    {"name":"Mike"},
    {"name":"chris"},
    {"name":"chrom"}
];

Basically I want to filter the array based on name of customer. if I give "ch" in the input text box it should give filter and give chris and chrom.

1 Answer 1

1

You want to filter based on cust name but cust is just a string, so not sure what you currently have is doing. Correct way would be :

<div ng-repeat="customer in customers| filter :{name : cust}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.