In a directive, I am creating a textbox on-the-fly and the validation along 
with it.  
  
The texbox is being created correctly and works.  
    
See plnker:  
  https://plnkr.co/edit/YJIwS8bD0w5e9LbWBtlJ?p=preview

BUT the error div ng-show is not being generated corretly from the 
directive's propErrPattern: '=' AND propErrReqr: '='.  

I have tried at least a dozen ways but nothing works.  The template is 
generating:  

    <p class="error" ng-show="propErrPattern || propErrReqr">
        <b class="ng-binding">Required. Length:-  Characters:</b> Letters, 
Numbers, Dash, Underscore, Space
    </p>
    
    <!-- instead of generating   -->
    <p class="error" ng-show="FirstName.$error.pattern || 
irstName.$error.required">

    
    app.directive('textBox', function () {
        return {
            scope: {
                label: '@label',
                value: '@value',
                property: '=',
                propErrPattern: '=',
                propErrReqr: '=',
                lenMin: '@lenMin',
                lenMax: '@lenMax',
            },
            restrict: 'E',
            replace: true,
            templateUrl: 'textboxTemplate.html'
        };
    });

In a form I call the directive by:  
    <text-box 
        label="First Name" 
        value="FirstName" 
        property='FirstName' 
        propErrPattern='FirstName.$error.pattern' 
        propErrReqr='FirstName.$error.required' 
        lenMin='3' 
        lenMax='15'>
    </text-box>
    
    
The textboxTemplate.html  

    <div class="form-group">
        <label for="{{value}}" class="control-label 
col-sm-4">{{label}}</label>
        <div class="col-sm-8">
            <input type="text"
                   class="form-control"
                   id="{{value}}"
                   name="{{value}}"
                   ng-model="property"
                   ng-pattern="/^[a-z\d\-_\s]+$/i" 
                   ng-minlength="{{lenMin}}"
                   ng-maxlength="{{lenMax}}"
                   ng-trim="true"
                   required />
            <!-- NOT GENERATING CORRECTLY -->
            <!-- NOT GENERATING CORRECTLY -->
            <p class="error" ng-show="propErrPattern || propErrReqr" >
                <b>Required. Length:{{lenMin}}-{{lenMax}}  Characters:</b> 
Letters, Numbers, Dash, Underscore, Space
            </p>
        </div>
    </div>


-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to