javascript - How to pass string to a function inside a directive in AngularJS? -


this templating function custom directive have created. string str passed function obtaindynamicfield(str) coming undefined. str string , not variable.

 function gettemplate() {             return  '           <td>' +             '       <div class="inner">' +             '                   <input type="text" ' +             '                               class="form-control" ' +             '                               data-dynamic-field="obtaindynamicfield(str)"'+             '                               data-ng-model="formdata.product" >' +             '                           </input>' +             '                       </div>' +             '           </td>' +  

i struggling past 2-3 hours in this. think need escape out str unable think far on how achieve it. kindly suggest.

you need escape ' around string:

'data-dynamic-field="obtaindynamicfield(\'str\')"'


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -