How to conditionally apply attribute in angularJS directive? -
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 "required" word in input tag shows when set true , word disappear when set false. help?
use ngrequired control required attribute in angular.
update template to
<input id="id" class="form-control" name="thename" type="text" ng-required="required">