Skip to content

Instantly share code, notes, and snippets.

@MarZab
Created February 5, 2015 20:21
Show Gist options
  • Save MarZab/6b8cda742768b9915146 to your computer and use it in GitHub Desktop.
Save MarZab/6b8cda742768b9915146 to your computer and use it in GitHub Desktop.
angular-schema-form + ngStrap Select
form: [
{
"key": "wizzard",
"type": "strap-select"
},
]
// schemaForm ngStrap Select
angular.module('schemaForm')
.config(function (schemaFormProvider, schemaFormDecoratorsProvider) {
//Add to the bootstrap directive
schemaFormDecoratorsProvider.addMapping(
'bootstrapDecorator',
'strap-select',
'directives/decorators/ngStrap/select.html'
);
})
.run(function ($templateCache) {
$templateCache.put("directives/decorators/ngStrap/select.html",
"<div class=\"form-group {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\">" +
"<label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>" +
"<br/><button name=\"{{form.key.slice(-1)[0]}}\" data-placeholder=\"{{form.placeholder}}\" data-animation=\"am-flip-x\" ng-model-options=\"form.ngModelOptions\" type=\"button\" class=\"btn btn-default\" ng-model=\"$$value$$\" ng-disabled=\"form.readonly\" data-html=\"1\" data-multiple=\"1\" sf-changed=\"form\" schema-validate=\"form\" ng-options=\"item.value as item.name for item in form.titleMap\" bs-select></button>" +
"<div class=\"help-block\" ng-show=\"(hasError() && errorMessage(schemaError())) || form.description\" ng-bind-html=\"(hasError() && errorMessage(schemaError())) || form.description\"></div>" +
"</div>");
});
schema: {
type: 'object',
properties: {
wizzard: {
"type": "array",
"items": {
"type": "string",
"enum": ['Something','Blah','Blaah']
}
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment