Home > Web Front-end > JS Tutorial > body text

How to determine whether an element is contained in an angularjs array

亚连
Release: 2018-06-04 10:48:55
Original
3721 people have browsed it

Below I will share with you an example of determining whether an angularjs array contains a certain element. It has a good reference value and I hope it will be helpful to everyone.

This is the in_array function, which determines whether an array contains an element.

  Array.prototype.in_array = function(e)
  {
    for(i=0;i<this.length;i++)
    {
      if(this[i] == e)
        return true;
    }
    return false;
  }
Copy after login

How to use:

tmp.in_array(id)
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to use js to determine that the input box cannot be a space or a null value?

How to use vue to determine if the input content is all spaces?

How to return to the top through the tween method in the vue project

The above is the detailed content of How to determine whether an element is contained in an angularjs array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!