text: (function() {
      
      "use strict";
      
      angular.module('common.modal', [])
          
      .directive('modal', ['Modal', function(Modal){
          return {
              restrict: 'E,A',
              link: function postLink(scope, element, attrs) {
                  element.bind( "click", function(){
                      Modal.load(attrs.modal, scope);
                  });
              }
          };
      }])
  
      .factory('Modal', ['$http', '$compile', function ($http, $compile) {
          // Got the idea for this from a post I found. Tried to not have to make this
          // object but couldn't think of a way to get around this
          var modalService = {};
      
          // Get the popup
          modalService.getModal = function() {
              $('.modal-service').remove();
      
              // the popup-service class lets us tag this modal for future manipulation
              modalService.modalElement = $('<div class="modal-service modal fade"><div class="modal-dialog"><div class="modal-content"></div></div></div>' );
              modalService.modalElement.appendTo('body');
      
              return modalService.modalElement;
          };
      
          modalService.compileAndRunPopup = function (modal, scope) {
              $compile(modal)(scope);
              modal.modal();
          };
      
      
          // Loads the modal
          modalService.load = function(url, scope) {
              $http.get(url).success(function (data) {
                  var modal = modalService.getModal();
      
                  modal.find('.modal-content').html(data);
                  modalService.compileAndRunPopup(modal, scope);
      
                  modal.on('hidden', function() {
                      modal.remove();
                  });
      
                  modal.find(".btn-cancel").click(function () {
                      modalService.close();
                  });
              });
          };
      
          modalService.close = function() {
              var modal = $('.modal-service');
              if (modal) {
                  modal.modal('hide');
              }
          };
      
          return modalService;
      }]);
      
  })();