angular-modal-service2.js
function(template, templateUrl) {
          var deferred = $q.defer();

          if (template) {
            deferred.resolve(template);

          } else if (templateUrl) {
            //  Check to see if the template has already been loaded.
            var cachedTemplate = $templateCache.get(templateUrl);

            if (cachedTemplate) {
              deferred.resolve(cachedTemplate);

            } else {
              //  If not, let's grab the template for the first time.
              $http.get(templateUrl).then(function(result) {

                //  Save template into the cache and return the template.
                $templateCache.put(templateUrl, result.data);

                deferred.resolve(result.data);

              }, function(error) {
                deferred.reject(error);
              });
            }

          } else {
            deferred.reject('No template or templateUrl has been specified.');
          }

          return deferred.promise;
        }
function(template, templateUrl) {
          var deferred = $q.defer();

          if (template) {
            deferred.resolve(template);

          } else if (templateUrl) {
            //  Check to see if the template has already been loaded.
            var cachedTemplate = $templateCache.get(templateUrl);

            if (cachedTemplate) {
              deferred.resolve(cachedTemplate);

            } else {
              //  If not, let's grab the template for the first time.
              $http.get(templateUrl).then(function(result) {

                //  Save template into the cache and return the template.
                $templateCache.put(templateUrl, result.data);

                deferred.resolve(result.data);

              }, function(error) {
                deferred.reject(error);
              });
            }

          } else {
            deferred.reject('No template or templateUrl has been specified.');
          }

          return deferred.promise;
        }
function ( template , templateUrl ) { var deferred = $q . defer ( ) ; if ( template ) { deferred . resolve ( template ) ; } else if ( templateUrl ) { //  Check to see if the template has already been loaded. var cachedTemplate = $templateCache . get ( templateUrl ) ; if ( cachedTemplate ) { deferred . resolve ( cachedTemplate ) ; } else { //  If not, let's grab the template for the first time. $http . get ( templateUrl ) . then ( function ( result ) { //  Save template into the cache and return the template. $templateCache . put ( templateUrl , result . data ) ; deferred . resolve ( result . data ) ; } , function ( error ) { deferred . reject ( error ) ; } ) ; } } else { deferred . reject ( 'No template or templateUrl has been specified.' ) ; } return deferred . promise ; }
Returns a promise which gets the template, either from the template parameter or via a request to the templateUrl parameter.
Returns a promise which gets the template either from the template parameter or via a request to the templateUrl parameter .