AngularJS custom directive to build a HTML element dynamically : Issue with binding a dynamic value to ng-model
<p>I've created a custom directive to create HTML elements dynamically. As part of this I'm passing JSON values dynamically to my custom directive to create attributes for the HTML element inside my custom directive. Here, I'm trying to pass a string value to be bound to the <code>ng-model</code> but it's considering the dynamic JSON value as a string literal instead of a property to hold the input value. </p>

<p>Another interesting point is, it is working fine if I pass the property name as a hard coded value to the custom directive. But I want to pass a dynamic value to be treated as the property name to be bound to the <code>ng-model</code>. Could you please help me on this?</p>

<p>Here is my code and it's not working. Not sure what's wrong. Please suggest me.</p>

<p>Inside my HTML file, below is what I'm using: </p>

<p></p>

<p>Inside my custom directive, I've below snippets:</p>

<pre><code>app.directive('myCustomDirective', ['$compile', '$parse', function ( $compile, $parse) {
    return {
             restrict:'E',
             replace : true,
             require: '?ngModel',
    scope: {
       dynamicmodel  :'=dynamicmodel'
    },

     template : '&lt;input type="text" ng-model="dynamicmodel" /&gt;',

     link : function(scope, element, attributes, frmCntrl) {

     }

        }
    }]);
</code></pre>