0

This is the templating function for the custom directive which I have created. The string str passed to the function obtainDynamicField(str) is coming as undefined. Also str is a string and not a 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 am struggling for the past 2-3 hours in this. I think I need to escape out the str which I am unable to think so far on how to achieve it. Kindly suggest.

2
  • 1
    Sorry, maybe I misunderstood the question, but you need to pass a string? So something like this? 'data-dynamic-field="obtainDynamicField(\'str\')"'? Commented Jul 25, 2016 at 15:33
  • @rpadovani: Impressive, captivating. Give it as an answer and I will mark it as an answer. Commented Jul 25, 2016 at 15:37

1 Answer 1

1

You just need to escape the ' around the string:

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.