Angular JS textbox validation allow particular text restrict other values
<p>I want to restrict the user to type other than "open" or "closed" string values.</p>

<p>that means user can only type "open" or "closed" text and also maxlength is 6. created the directive for that, but  still it is allowing other text values, how to capture or allow user to type only those two text values.</p>

<p>plunkr link</p>

<p><a href="http://plnkr.co/edit/LFbPbRAMyYZGhTZ1F7GU?p=preview" rel="nofollow">http://plnkr.co/edit/LFbPbRAMyYZGhTZ1F7GU?p=preview</a></p>

<pre><code>var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {


});

app.directive('wmBlock', function ($parse) {
    return {

        link: function (scope, elm, attrs) {

          elm.bind('keypress', function(e){

            if(scope.foo==="open" || scoe.foo==="closed"){
              return true;
            }
            else
            {
               e.preventDefault();
              return false;
            }
            }
          });
        }
    }   
});
</code></pre>