角度7封装的表格生成器

时间:2019-07-08 11:35:37

标签: angular angular7 formbuilder angular2-formbuilder

嗨,我正在使用以下formbuilder

  

版本

  • Form-b​​uilder版本:3.2.5
  • 角版本:7.2.1
  • @ types / jquery“:” ^ 3.2.11
  • @ types / jqueryui“:” ^ 1.11.35
  • jquery”:“ ^ 3.2.1”
  • jquery-ui-sortable”:“ ^ 1.0.0”
  • Windows平台
  

问题

当我将div与form-b​​uilder绑定时,它表明未定义操作,并且我参考了form-b​​uilder官方文档,但操作错误仍然相同。

请帮助我解决错误

  

错误图片

enter image description here

我在下面添加了我ts文件的所有代码

function  initJq() {
  (  function ($) {
    debugger
    (<any>$.fn).formBuilder =  function (options) {
      debugger
      if (!options) {
        options = {}; 
      }
      let elems = this;
      let {i18n, ...opts} = $.extend({}, defaultOptions, options, true);
      (<any>config).opts = opts;
      let i18nOpts = $.extend({}, defaultI18n, i18n, true);
      let instance = {
        actions: {
          getData: null,
          setData: null,
          save: null,
          showData: null,
          setLang: null,
          addField: null,
          removeField: null,
          clearFields: null
        },
        get formData() {
          let a= instance.actions.getData('json');
          data
          return a;
        },
        promise: new Promise(function (resolve, reject) {
          new I18N().init(i18nOpts).then(() => {
            elems.each(i => {
             let formBuilder = new FormBuilderCreateor().getFormBuilder(opts, elems[i]);

              $(elems[i]).data('formBuilder', formBuilder);
              instance.actions = formBuilder.actions;
            });
            delete instance.promise;
            resolve(instance);
          }).catch(console.error);
        })

      };
      return instance;
    };
  })(jQuery);
}
@Component({
    selector   : 'sample',
    templateUrl: './sample.component.html',
    styleUrls  : ['./sample.component.scss']

})
export class SampleComponent implements OnInit {
public formBuilder:any
  ngOnInit(): void { 
   initJq();
   (<any>jQuery('.build-wrap')).formBuilder();
  }
}

0 个答案:

没有答案