2016-08-12 6 views
2

特定のラジオボタンを選択する必要があるため、ラジオボタンにいくつかのデフォルト値を設定します。このために、(controlDirectives.js)ファイルにradioControlDirというディレクティブを作成しました。角型Jsで値を設定するラジオボタンでディレクティブを呼び出す方法

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はngmodelが値を持っていない場合に設定される値を持っています。テキストと選択のための他のディレクティブは正常に動作しています。

答えて

1

要素を意味する制限値 'E'があるためだと思います。

「A」(属性)である必要があります。

また、queObj._pageAttributes.defaultValueは ""ですが、ラジオではこのラジオの値に 'Y'のように設定する必要があります。

function radioControlDir() 
    { 
     return { 
      transclude: true, 
      restrict: 'A', 
      scope: { 
       ngModel: '=', 
       queObj: '=' 
      }, 
      link: function (scope, element, attrs) 
      { 

       if(angular.isUndefined(scope.ngModel)) 
       { 

       scope.ngModel = 'Y'; 
       } 
      } 
     }; 
    } 
関連する問題