Home >Web Front-end >JS Tutorial >How to determine whether an element is contained in an angularjs array

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

亚连
亚连Original
2018-06-04 10:22:173751browse

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;
  }

How to use:

tmp.in_array(id)

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!

Statement:
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