Reputation: 2377
I want to set some default value to radio button, as per the value particular radio button should be selected. For this I created a directive radioControlDir in (controlDirectives.js) file.
function controlDir()
{
return {
transclude: true,
restrict: 'E',
scope: {
ngModel: '=',
queObj: '='
},
link: function (scope, element, attrs)
{
if(angular.isUndefined(scope.ngModel))
{
scope.ngModel = 'Y';
}
}
};
}
scope.queObj._pageAttributes.defaultValue has value that will be set if ngmodel do not have value. Other directive for text and select is working fine.
Upvotes: 2
Views: 63
Reputation: 1441
I think it is just because you have the restrict value 'E' which means element.
It should be 'A' (attribute);
And in the plunker the queObj._pageAttributes.defaultValue
is "", but for radio you need set it to the value for this radio like 'Y';
function radioControlDir()
{
return {
transclude: true,
restrict: 'A',
scope: {
ngModel: '=',
queObj: '='
},
link: function (scope, element, attrs)
{
if(angular.isUndefined(scope.ngModel))
{
scope.ngModel = 'Y';
}
}
};
}
Upvotes: 1