I have a simple component where I've placed multiple buttons and I want to show those buttons in another component (functionality of buttons also comes from my buttons component) but i get this error in terminal
ERROR NullInjectorError: R3InjectorError(HelpdeskModule)[ButtonsComponent -> ButtonsComponent -> ButtonsComponent -> ButtonsComponent]:
NullInjectorError: No provider for ButtonsComponent!
Code
buttons.component.html
<div class="mb-3">
<nz-button-group>
<button nz-button nzType="primary" (click)="buttonClick('create button')" class="ant-btn ant-btn-primary ant-btn-lg"><i nz-icon nzType="download"></i>Create New</button>
</nz-button-group>
</div>
list.component.ts (this is where i want to show those components)
import { ButtonsComponent } from 'src/app/components/app/layout/buttons/buttons.component';
constructor(
private buttons: ButtonsComponent,
) { }
And list.component.html
// I am uncertain about this part to be correct at all!
{{buttons}}
Any idea?
Update
I've added Injectable to my buttons component like this: (just playing around to get them printed )
import { Component, OnInit, Injectable } from '@angular/core';
import { NzNotificationService } from 'ng-zorro-antd'
@Component({
selector: 'app-buttons',
templateUrl: './buttons.component.html',
styleUrls: ['./buttons.component.scss']
})
@Injectable({
providedIn: 'root'
})
export class ButtonsComponent implements OnInit {
//
}
and now I'm getting this error
ERROR TypeError: Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.