Comments (2)
it worked
when initialized Formio.registerComponent('custom', CustomComponent); in the constructed of the component in which i wanted to use formio.
from help.form.io.
Hi @Navpreet2289
i tried with the Angular 6 starter application ( https://github.com/formio/angular-app-starterkit ) to get a custom component to work. But i am not able to import the BaseComponent. The Formio component is working fine when when i adjust the import statement to:
import { Formio } from 'formiojs';
For the BaseComponent
import { BaseComponent } from 'formiojs/build/components/base/Base'
i got the error message - Module not found:
ERROR in src/app/custom/custom.component.ts(2,31): error TS2307: Cannot find module 'formiojs/build/components/base/Base'
I figured out, that the location of the base component has been changed. So i tried to adjust the import statement to the new location:
import * as BaseComponent from 'formiojs/components/base/Base';
Then i extend the CustomComponent from BaseComponent. Now the app starts, but i got a similar error from your first post.
compiler.js:1016 Uncaught Error: Can't resolve all parameters for CustomComponent: (?, ?, ?).
at syntaxError (compiler.js:1016)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (compiler.js:10917)
My Code:
`import { Component } from '@angular/core';
import * as BaseComponent from 'formiojs/components/base/Base';
console.log(BaseComponent.default);
@component({
selector: 'app-custom',
template: '<p>My Component</p>
'
})
export class CustomComponent extends BaseComponent.default {
constructor(component, options, data) {
super(component, options, data);
}
elementInfo() {
let info = super.elementInfo();
info.type = 'input';
info.changeEvent = 'input';
return info;
}
}`
And App Component:
`import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { FormioResources } from 'angular-formio/resource';
import { FormioAuthService } from 'angular-formio/auth';
import { CustomComponent } from './custom/custom.component';
import { Formio } from 'formiojs';
@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app';
constructor(
private auth: FormioAuthService,
private router: Router,
public resources: FormioResources
) {
this.auth.onLogin.subscribe(() => {
this.router.navigate(['/home']);
});
this.auth.onLogout.subscribe(() => {
this.router.navigate(['/auth/login']);
});
this.auth.onRegister.subscribe(() => {
this.router.navigate(['/home']);
});
console.log(Formio.registerComponent);
Formio.registerComponent('custom', CustomComponent);
}
}`
Do you have any idea or solution?
Thanks a lot for your help :)
from help.form.io.
Related Issues (20)
- cannot pull formio/formio-files-core
- [BUG] Documentation for tree component is missing under Data Components section
- [BUG] Dynamically generate the data grid content
- load values to select component dynamically using javascript
- Complex Authorization system
- Select Boxes configuration to use max and min selection
- Create a component and set its size
- on click of submit button show a thankyou message with ok and cancel button
- Can a xaml request be created from form.io?
- [BUG] Not able to find any documentation for the "Logic" tab
- [HELP] calling loadRole and loadAction
- [HELP] Textfield phone validation on focusout with calculated value possible?
- Possible to add custom css for Select item
- Image is not displayed in the label section for general settings under form components.
- [BUG]
- [BUG] mobile looks nasty and unreadable in places HOT 1
- [BUG] Documentation on button element is out of date HOT 1
- Versioning - Increment vid on change of something other than components? HOT 2
- [BUG] Documentation for tabs component is missing under Layout Components section
- [UNDOCUMENTED? or NOT-SUPPORTED?] setting the form default value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from help.form.io.