'use strict';

app.directive('customDeviceForm', function (){
  return {
    restrict: 'EA',
    require: 'ngModel',
    replace: true,
    scope: {
      device: '=ngModel',
      formName: '='
    },
    templateUrl: 'views/installer/new/devices/write-in.html',
    controller: function ($scope) { 

      $scope.$watch('device.db.source', function(newValue, oldValue) {
        
        if (newValue === 'CUSTOM') {
          $scope.device.target.type = 1;
          $scope.device.db.brand = null;
          $scope.device.db.model = {}; 
        }
      });

      

    } 
  };
});
