[CORD-1539] Support for static choices and default values
Change-Id: I988b1863221a0678aff1bd151fb2d26e1a33fe92
diff --git a/src/app/core/field/field.ts b/src/app/core/field/field.ts
index 5c5b48a..f05a8e4 100644
--- a/src/app/core/field/field.ts
+++ b/src/app/core/field/field.ts
@@ -38,6 +38,16 @@
throw new Error('[xosField] Please provide an ng-model');
}
+ // NOTE set default value (if any)
+ if (this.field.default && !angular.isDefined(this.ngModel)) {
+ if (this.field.type === 'number') {
+ this.ngModel = parseInt(this.field.default, 10);
+ }
+ else {
+ this.ngModel = this.field.default;
+ }
+ }
+
if (this.field.type === 'array') {
this.$scope.$watch(() => this.ngModel.length, () => {