Ошибка: не удается разрешить все параметры для DynamicFormComponent ([объект объекта], [объект объекта], [объект объекта]? - PullRequest
0 голосов
/ 14 декабря 2018

Я хочу вызвать одну компонентную функцию в другом компоненте, но выдает следующую ошибку

Ошибка: невозможно разрешить все параметры для DynamicFormComponent: ([объект объекта], [объект объекта],[объект Объект], [объект Объект].

Пожалуйста, помогите мне, где я сделал неправильно?

Вот мой код:

#Component1

export class DynamicFormComponent implements OnInit {
    constructor(private auth: AuthService, private _http: HttpClient, private data: DataShareService, private toastr: ToastrService, private globals:GlobalConstants) {
    }

    getSelectedName(memObj:any) {
        alert("mem pension " + memObj.id);
    }
}

# Component 2

@Component(
         { selector: 'app-form-autocomplete-type', 
            template: `  
            <input matInput
            [matAutocomplete]="auto"
            [formControl]="formControl"
            [formlyAttributes]="field"
            [placeholder]="to.placeholder">   <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
            <mat-option
              *ngFor="let value of filter | async"
              [value]="value" (onSelectionChange)=updateValues(value)>
              {{ value.userGroupName }}
            </mat-option>   </mat-autocomplete>   `, }) 
export class AutocompleteTypeComponent extends FieldType implements OnInit {   
     // Optional: only if you want to rely on `MatInput` implementation   
     @ViewChild(MatInput) formFieldControl: MatInput;

     filter: Observable<any[]>;

     constructor(public dynamicFormComponent:DynamicFormComponent) {
        super();
     }

     ngOnInit() {
        this.filter = this.formControl.valueChanges
              .pipe(
                startWith(''),
                switchMap(term => this.to.filter(term)),
              );   
     }

     updateValues(val: any) {
         // Call service to fetch the details and update other formly fields values
         // update the rank and address formly fields based on the results we fetch from service.It may be single field or a group of fields.
         console.log("Call service to fetch the details and update other formly fields values");
         // this.dynamicFormComponent.getSelectedName(val);
     } 
 }
...