GUAC-1176: Allow field types to define hard-coded HTML templates (without a URL).

This commit is contained in:
Michael Jumper
2015-06-08 13:02:45 -07:00
parent b3e5827dea
commit a96b7756a9
2 changed files with 30 additions and 11 deletions

View File

@@ -241,6 +241,13 @@ angular.module('form').provider('formService', function formServiceProvider() {
// Defer compilation of template pending successful retrieval
var compiledTemplate = $q.defer();
// Use raw HTML template if provided
if (fieldType.template)
compiledTemplate.resolve($compile(fieldType.template)(scope));
// If no raw HTML template is provided, retrieve template from URL
else {
// Attempt to retrieve template HTML
templateRequest(fieldType.templateUrl)
@@ -254,6 +261,8 @@ angular.module('form').provider('formService', function formServiceProvider() {
compiledTemplate.reject();
});
}
// Return promise which resolves to the compiled template
return compiledTemplate.promise;

View File

@@ -38,9 +38,19 @@ angular.module('form').factory('FieldType', [function defineFieldType() {
// Use empty object by default
template = template || {};
/**
* The raw HTML of the template that should be injected into the DOM of
* a form using this field type. If provided, this will be used instead
* of templateUrl.
*
* @type String
*/
this.template = template.template;
/**
* The URL of the template that should be injected into the DOM of a
* form using this field type.
* form using this field type. This property will be ignored if a raw
* HTML template is supplied via the template property.
*
* @type String
*/