0

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?

1 Answer 1

1

In the Ng-Lightning, activeName is defined here :

enter image description 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';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.