Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:08:35+00:00 2026-06-13T10:08:35+00:00

I was playing with angular.js the other day and I found this filter function,

  • 0

I was playing with angular.js the other day and I found this filter function, that angular.js provides for us.

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span2">
      <!--Sidebar content-->

      Search: <input ng-model="query">

    </div>
    <div class="span10">
      <!--Body content-->

      <ul class="phones">
        <li ng-repeat="phone in phones | filter:query">
          {{phone.name}}
          <p>{{phone.snippet}}</p>
        </li>
      </ul>

    </div>
  </div>
</div>

My question is: Can I use angular.js filter on premade html elements, somehing like this.

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span2">
      <!--Sidebar content-->

      Search: <input ng-model="query">

    </div>
    <div class="span10">
      <!--Body content-->

      <ul class="phones" ng-filter:query>
        <li>First element</li>
        <li>Second elementy/li>
        <li>Third element</li>
      </ul>

    </div>
  </div>
</div>

Thank you for your answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:08:36+00:00Added an answer on June 13, 2026 at 10:08 am

    For this kind of DOM manipulation/filtering, Angular directives ngSwitch or ngShow/ngHide are normally used.

    <ul class="phones" ng-switch on="query">
    <li ng-switch-when="Nexus S">First element</li>
    

    The above would look for an exact match though (so it is not as nice as @tosh’s directive). ng-switch is often used with a select drop-down, where the possible values are fixed/known.

    ngShow/ngHide are probably a better match for what you are trying to do. An in-line expression or $scope function can be used to determine whether to show an element:

    <li ngShow="some expression using query">First element</li>
    <li ngShow="myFilter()">First element</li>
    
    function MyCtrl($scope) {
        $scope.myFilter = function() {
           if($scope.query ...) {  // could use RegExp() here like @tosh
              return true
           }
           return false
        }
    

    The above does not require jQuery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im playing a little bit with heavy-client app. Imagine I have this model: class
Playing with Git and GitHub,I found that sometimes a git commit -a is needed
Playing around with MSVC++ 2005, I noticed that if the same class is defined
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
While playing with standard library i've found a strange difference between python2 and python3.
been playing around with ResolveClientUrl(~/Confirmation.aspx) and other methods.. I am tryin go get the
Playing with Erlang, I've got a process-looping function like: process_loop(...A long list of parameters
While playing around with the emulator, I noticed that when trying to view a
been playing with this for a few hours and can't figure it out. jsFiddle
I'm currently playing around with RestEasy and Angular.js. I'm trying to return a collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.