module.exports = angular
  .module('simditor.directive', [])
  .directive('simditor', simditor);

simditor.$inject = ['simditorOptions'];

function simditor(simditorOptions) {
  return {
    restrict: 'AE',
    require: 'ngModel',
    link: function(scope, element, attr, ngModel) {
      if (!ngModel) return;

      var $textarea = angular.element('<textarea placeholder="' + attr.placeholder + '"></textarea>');
      element.append($textarea);

      var config = angular.extend({
        textarea: $textarea
      }, simditorOptions);

      var editor = new Simditor(config);

      ngModel.$render = function() {
        editor.setValue(ngModel.$viewValue || '');
      };

      editor.on('valuechanged', function(e) {
        ngModel.$setViewValue(editor.getValue());
      });

    }
  };
};

module.exports = angular
  .module('simditor.directive', [])
  .directive('simditor', simditor);

simditor.$inject = ['simditorOptions'];

function simditor(simditorOptions) {
  return {
    restrict: 'AE',
    require: 'ngModel',
    scope: {
      options: '<'
    },
    link: function(scope, element, attr, ngModel) {
      if (!ngModel) return;

      var options = scope.options || {};

      if (attr.placeholder != null) {
        options.placeholder = attr.placeholder;
      }

      var $textarea = angular.element('<textarea></textarea>');
      element.append($textarea);

      var config = angular.extend({
        textarea: $textarea
      }, simditorOptions, options);

      var editor = new Simditor(config);

      ngModel.$render = function() {
        editor.setValue(ngModel.$viewValue || '');
      };

      editor.on('valuechanged', function(e) {
        ngModel.$setViewValue(editor.getValue());
      });

    }
  };
};

Add option to pass options object to ng-simditor
Add option to pass options object to ng-simditor
