title: How to dynamically add ng-options for select in custom directive of angularJS?
body: <p>Not sure, it is the correct approach or not.</p>
  
  <ol>
  <li><p>Inside html file, I just use below code: </p>
  
  <pre><code>select id="family" nt-field="true"/
  </code></pre></li>
  <li><p>ntModule.js </p>
  
  <pre><code>.directive('ntField', ['$document', function($scope,$document) {
      return {
          link: function(scope, element, attr) {
              var type = element[0].type;
              switch(type){
              case 'select-one':
                  var id = element[0].id;
                  switch(id){
                  case 'family':
                      scope.selectOptions = "opt.desc for opt in serviceRenewal.system.controller.families.options track by opt.name";
                      attr.$set('ng-options',scope.selectOptions);
                      attr.$set('ng-model','familyModel');
                      attr.$observe('ng-options',function(value){
                          console.log(value);
                      });
                      break;
                  }
  
                  break;
  
              }
  
          }
      }
  </code></pre></li>
  </ol>
  
  <p>I am newbie in angularJS. </p>