angularjs - How to pass down ng* attributes in a custom directive? -


I have created a custom "BS-Input" instruction that wraps the input field in the bootstrap template. If I fill all the attributes (type, max-length, expected, pattern, etc.) then it works fine. However,

The field does not work due to the maximum length recognition and ng-pattern recognition (eg a regexp), the field is considered invalid. How can I pass an undefined variables on input tags, or if they do not have any value, then conditionally exclude them?

Here's my instruction:

  mod.directive ('BS Input', function () {return: {AC :, requirement: '^ form', template: ' & Lt; div ng-form = "innerform" class = "form-group" ng-class = "getFieldClass ()" & gt; {{eLabel | tt}} & lt; / label & gt; for & gt; ; Label class = "control-label" ng-square = "{\ 'col-sm-5 \': eVertical}";> 

You should define your instructions that your properties are optional eg.

  scope: {ngModel: "=", eLabel: "@", type: "@", imaxlamth: "@?", & Lt; --------- ERequired: '=', ePattern: '@', Evertical: '=', E-Disposed: '=', E Placeholder: '@', e-Help: '@'}  

Check the link function that your ultimate is undefined, if it is, set it to an empty string. The browser will not validate against:

  link: function (scope, amm, etters) {if (scope.emaxLength === undefined) {scope.emaxLength = ''; }}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -