嗨,我正在使用以下formbuilder
版本
问题
当我将div与form-builder绑定时,它表明未定义操作,并且我参考了form-builder官方文档,但操作错误仍然相同。
请帮助我解决错误
错误图片
我在下面添加了我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();
}
}