Below is a directive I am working with:
.directive('gdInputField', function() {
return {
//only applies to elements, not attributes.
restrict: 'E',
template: "<label for='{{name}}'>{{label}}</label><input name='{{key}}' id='{{name}}' type='{{type}}' ng-required='{{required}}' /><p>{{entry.1949113882}}</p>",
scope: {
label: '@label',
name: '@name',
key: "@key",
required: "@required",
type: "@type"
},
};
})
I want the value set with @key to be the model name for the input field. If I use ng-model='key'
, it shows the @key string as the content of ng-model.
This seems to be the outcome:
$scope={
someting: @key
}
What I actually need is:
$scope={
@key: '';
}
If the user inputs something in the field, @key should update accordingly.
Additionally, what is the current name of the model binding or how can I determine that?