title: How to use angular factory to create html object and use it view
body: <p>I need to create <code>html</code> object and pass it in view, as in code below if I use function mentioned in <code>factory</code> directly into the controller it works just fine but I need to reuse the function mentioned in <code>factory</code> at multiple places in-app and I'm trying to avoid repeating same code in my application, I'm kind of new to Angular and stuck at this.</p>
  
  <p>factory:</p>
  
  <pre><code>angular.module('mainApp').factory('RichEditorControl', function () {
  
      function createRichEdit(richEditContainer) {
          var options = DevExpress.RichEdit.createOptions();
          options.height = '1000px';
          customizeRibbon(options);
          options.confirmOnLosingChanges.enabled = false;
  
          var elem = document.createElement('div');
          richEditContainer.append(elem);
  
          var rich = DevExpress.RichEdit.create(elem, options);
  
          window.rich = rich;
  
          return rich;
      }
  
      function customizeRibbon(options) {
          // options.ribbon.removeTab(DevExpress.RichEdit.RibbonTabType.MailMerge);
          options.ribbon.removeTab(DevExpress.RichEdit.RibbonTabType.References);
          options.ribbon.getTab(DevExpress.RichEdit.RibbonTabType.File)
              .removeItem(DevExpress.RichEdit.FileTabItemId.OpenDocument);
          options.ribbon.getTab(DevExpress.RichEdit.RibbonTabType.View)
              .removeItem(DevExpress.RichEdit.ViewTabItemId.ToggleShowHorizontalRuler);
      }
  
  })
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>app.controller('AppCtrl',
  [
      '$scope', '$http', '$timeout', '$log', '$q', '$location', 'RichEditorControl', function ($scope, $http, $timeout, $log, $q, $location, RichEditorControl) {
  
          RichEditorControl.createRichEdit($(angular.element('#rich-container')));
      }
  ]);
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
      &lt;div style="height: 1024px;" id="rich-container"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>