I created directive for form controls[input, select and radio], Each input have default value, if $scope.answers have this input value then this value should show in input box.
Below code is not working from link fucntion
if($scope.answers.PC && $scope.answers.PC != '')
{
element.val = $scope.answers.PC;
}
Directive function
function textControlDir()
{
return {
transclude: true,
restrict: 'E',
scope: {
queObj: '=',
},
template: '<div class="form-group">\n\
<label for="{{queObj._attributeName}}" class="col-sm-5 control-label">{{queObj._text}}</label>\n\
<div class="col-sm-6"><input type="text" name="{{queObj._attributeName}}" class="form-control" id="{{queObj._attributeName}}" value="{{queObj._pageAttributes.defaultValue}}"></div>\n\
</div>'
,
link: function ($scope,scope, element, attrs)
{
if($scope.answers.PC && $scope.answers.PC != '')
{
element.val = $scope.answers.PC;
}
console.log($scope);
}
};
}
HTML
<text-control-dir data-que-obj="que.QuestionData"></text-control-dir>