Reputation: 10964
I am trying to use the Accordion component from the Ng-Lightning library.
My html:
<ul ngl-accordion [(activeName)]="active">
<ng-template nglAccordionSection name="B" label="Accordion Title A">This is the content area for section A
</ng-template>
</ul>
<div class="slds-m-top_large">Active Section Name: <b>{{ active | json }}</b></div>
and my component file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-list-item',
templateUrl: './list-item.component.html',
styleUrls: ['./list-item.component.scss']
})
export class SuggestedReferenceListItemComponent implements OnInit {
active='B';
constructor() { }
ngOnInit(): void {}
}
I'm seeing the following warning when trying to compile my code:
Error: src/app/list-item/list-item.component.html:3:35 - error TS2322: Type 'string | string[]' is not assignable to type 'string'.
Type 'string[]' is not assignable to type 'string'.
<ul ngl-accordion [(activeName)]="active">
Could anyone tell me why I'm seeing that warning and how to resolve it?
Upvotes: 0
Views: 723
Reputation: 502
In the Ng-Lightning, activeName is defined here :
And your component active='B'; is defined only like a string.
So, u can try :
active: string | string[] = 'B';
or if it really doesn't work
active: any = 'B';
Upvotes: 1