In html:
<cms-text required="false" id="product_name" thename="product_name"></cms-text>
In cmsText.js
angular.module('cmsText',[]).directive('cmsText', function(){
'use strict';
return {
restrict: 'EA',
scope: {
thename:'=',
required:'=',
id:'='
},
replace:true,
templateUrl: 'cms-text/cmsText.html',
};
});
In cmsText.html
<input id="id" class="form-control" name="thename" type="text" required>
I want the "required" word in input tag shows only when it is set to true and the word disappear when it is set to false. Anyone could help?
Use ngRequired to control the required attribute in Angular.
Update your template to
<input id="id" class="form-control" name="thename" type="text" ng-required="required">
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments