title: Angularjs check if passing value exists in array
body: <p>I'm trying to pass two text field values into and array using AngularJS, but I also want to check if the first value being passed already exists in the array. If it does I do not want it added again, if it doesn't exist then add the values. I can get it to add the values but I'm getting stuck trying to check if the last name value exists already in the array. I had found some examples I tried to follow but I cant seem to get them to work. Thanks for any help!</p>
  
  <pre><code>&lt;div class="panel-body"&gt;
      &lt;div ng-controller="TodoCtrl"&gt;
          &lt;ul&gt;
              &lt;li li ng-repeat="todo in todos"&gt;
              {{todo.text}}, {{todo.name}}
              &lt;/li&gt;
          &lt;/ul&gt;
          &lt;form class="form-horizontal"&gt;
          &lt;input type="text" ng-model="formTodoLast" ng-model-instant&gt;
          &lt;input type="text" ng-model="formTodoFirst" ng-model-instant&gt;
          &lt;button class="btn" ng-click="addTodo()"&gt;&lt;i class="icon-plus"&gt;&lt;/i&gt;Add&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>todo.js</p>
  
  <pre><code>function TodoCtrl($scope) { 
      $scope.todos = [];
  
      $scope.addTodo = function () {
  
      if($scope.todos.indexOf(text:$scope.formTodoLast) == -1) {
          $scope.todos.push({text:$scope.formTodoLast, name:$scope.formTodoFirst});
          $scope.formTodoText = ' ';
          $scope.formTodoName = ' ';
          }
      }
  }
  </code></pre>