title: passing an array to custom directive in angularjs
body: <p>I have the following directive </p>
  
  <pre><code>var notInModule = angular.module('ui.notIn', []);
  
  notInModule.directive('notIn', function() {
    return {
      restrict: 'A',
      require: 'ngModel',
      link: function(scope, elm, attrs, ctrl) {
          var thisValue;
          var otherValues;
  
          attrs.$observe('notIn', function(values) {
              otherValues = values;
              validate();
          });
  
          ctrl.$parsers.unshift(function(viewValue) {
              thisValue = viewValue.toLowerCase();
              validate();
              return thisValue;
          });
  
          var validate = function() {
              ctrl.$setValidity('isWithin', otherValues.some(function(value) {
                  return value.toLowerCase() === thisValue.toLowerCase();
              }));
          };
      },
  };
  </code></pre>
  
  <p>});</p>
  
  <p>and i am using it like this </p>
  
  <pre><code>&lt;input ng-model="sample.name" not-in={{sample}} required/&gt;
  </code></pre>
  
  <p>sample is an array on scope. However , in the directive 's controller , it comes in as a string. </p>
  
  <p>for eg :if <code>$scope.sample = ["a","b"]</code> , </p>
  
  <p>In the directive , values is got as <code>"["a","b"]"</code></p>