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"> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -