title: how to check value entered in input field is already available or not in angularjs
body: <p>I would like to know in the below example how can i check whether entered value in input field is already available or not. </p>
  
  <p>I have an input field, on key press i want  to check the input field value with the values from names array and display error message down if value is already present in names array and also disable the button. If value entered is not present in the names array i dont want to display error message and enable the Add button. Here is the plunkr - <a href="https://plnkr.co/edit/rz0tjxhEajz7848Ws3ig?p=preview" rel="nofollow noreferrer">https://plnkr.co/edit/rz0tjxhEajz7848Ws3ig?p=preview</a></p>
  
  <p>html - </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
    &lt;head&gt;
      &lt;script src="angular.min.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="style.css"&gt;
      &lt;script src="script.js"&gt;&lt;/script&gt;
  
    &lt;/head&gt;
  
    &lt;body ng-app="test" ng-controller="testController"&gt;
     Name: &lt;input type="text"/&gt;
     &lt;button on-keypress="submit()"&gt;Add&lt;/button&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>script - </p>
  
  <pre><code>var testController = angular.module('test', []);
  
  testController.controller('testController', ['$scope', function($scope) {
  
  
    $scope.names = ["name1","name2","name3"];
  
    angular.forEach($scope.names, function(x) {
  
      console.log(x);
    });
  }]);
  </code></pre>