Arpit Agarwal | 4397874 | 2016-08-09 15:38:25 -0700 | [diff] [blame^] | 1 | 'use strict';
|
| 2 |
|
| 3 | angular.module('ngXosLib')
|
| 4 | .component('formTest', {
|
| 5 | restrict: 'E',
|
| 6 | bindings: {},
|
| 7 | bindToController: true,
|
| 8 | controllerAs: 'vm',
|
| 9 | templateUrl: 'templates/form.dev.html',
|
| 10 | controller: function () {
|
| 11 | this.model = {
|
| 12 | first_name: 'Jhon',
|
| 13 | last_name: 'Doe',
|
| 14 | },
|
| 15 | this.config = {
|
| 16 | exclude: ['password', 'last_login'],
|
| 17 | formName: 'sampleForm',
|
| 18 | actions: [
|
| 19 | {
|
| 20 | label: 'Save',
|
| 21 | icon: 'ok', // refers to bootstraps glyphicon
|
| 22 | cb: (user) => { // receive the model
|
| 23 | console.log(user);
|
| 24 | },
|
| 25 | class: 'success'
|
| 26 | }
|
| 27 | ],
|
| 28 | fields: {
|
| 29 | first_name: {
|
| 30 | type: 'string',
|
| 31 | validators: {
|
| 32 | required: true
|
| 33 | }
|
| 34 | },
|
| 35 | last_name: {
|
| 36 | label: 'Surname',
|
| 37 | type: 'string',
|
| 38 | validators: {
|
| 39 | required: true,
|
| 40 | minlength: 10
|
| 41 | }
|
| 42 | },
|
| 43 | details_field: {
|
| 44 | label: 'Empty Object Field',
|
| 45 | type: 'object',
|
| 46 | properties: {
|
| 47 | foo: {
|
| 48 | label: 'FooLabel:',
|
| 49 | type: 'string',
|
| 50 | validators: {
|
| 51 | required: true
|
| 52 | }
|
| 53 | },
|
| 54 | bar: {
|
| 55 | type: 'number'
|
| 56 | }
|
| 57 | }
|
| 58 | }
|
| 59 | }
|
| 60 | }
|
| 61 | }
|
| 62 | }) |