angular icon indicating copy to clipboard operation
angular copied to clipboard

How can i create a Custom NestedComponent with Angular Components

Open Schwofel opened this issue 5 years ago • 3 comments
trafficstars

I don't want to use the CheckMatrix.js example. Is there a way that i can use a @Component and create a nested component with children and multiple drop zones?

Schwofel avatar Jan 16 '20 08:01 Schwofel

Custom components are actually just regular components included within your own application. There are many examples of nested components found @ the following locations.

  • https://github.com/formio/formio.js/blob/master/src/components/columns/Columns.js
  • https://github.com/formio/formio.js/blob/master/src/components/container/Container.js
  • https://github.com/formio/formio.js/blob/master/src/components/datagrid/DataGrid.js
  • https://github.com/formio/formio.js/blob/master/src/components/datamap/DataMap.js

and there are many more.

travist avatar Jan 16 '20 14:01 travist

@travist The question is about creating custom component with Angular component, not JS file component, like at this link: https://github.com/formio/angular/wiki/Custom-Components-with-Angular-Elements I'm interested in this question too, because I want to create an Angular component inherited from NestedComponent, but this way doesn't work for me, it says "Module not found: Error: Can't resolve 'formiojs/types/components/_classes/nested/nestedComponent'", but this module is accessible on this path. And an other question is what params I need to pass in super() constructor and where do I get them from?

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormioCustomComponent, FormioEvent } from '@formio/angular';
import { NestedComponent } from 'formiojs/types/components/_classes/nested/nestedComponent';

@Component({
  selector: 'app-spot-table',
  templateUrl: './spot-table.component.html',
  styleUrls: ['./spot-table.component.sass']
})
export class SpotTableComponent extends NestedComponent implements FormioCustomComponent<any>, OnInit {

  @Input() value: any;
  @Output() valueChange: EventEmitter<any>;
  @Input() disabled: boolean;

  constructor() {
    super(???);
  }

  ngOnInit(): void {
  }
}

dsovago avatar Jul 07 '21 15:07 dsovago

@dsovago did you have any success implementing the custom NestedComponent with multiple drop zones in Angular

davidyoung77 avatar Dec 05 '23 23:12 davidyoung77