2

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.

1 Answer 1

1

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';
              }
            }
        };
    }
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.