You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new TypeScript file.
Example: custom-template.ts
Define a single function, with one param called ctx. Inside the function define the html. You may reach config via the ctx param.
Example:
export default function(ctx: any) {
// console.log(ctx);
let p = `<div>Lorem Ipsum</div>`;
return p;
}
Register the template. Do it "somewhere" in the Angular scope, like in the constructor of an NgModule.
Example:
import customTemplate from './custom-template';
import { Templates } from 'angular-formio';
[...]
export class FormDesignerModule {
constructor() {
Templates.current.custom = {
form: fieldTemplate,
};
}
}
You can use this template for your custom formio component. The template will be called "custom" (due to defined as Templates.current.custom)
See the "Optional: define a template for the element." part in the docs.
If you found this useful I can add this to the wiki at some point.
Okay but shouldnt it be customTemplate not fieldTemplate? Im doing this and its stating that my template file is not a module. and how do i use this template in my formiocustomcomponent options?
Amazing work on this so far, Cant wait to see how this all works out!
How can i add a new template for my custom component?
The text was updated successfully, but these errors were encountered: