4

This issue is as good as this link but i need the array as dynamic!

FileName: app.component.html

<ques [card_title]="'Abc'" [card_text]="'What is Space'" [items]="{{items}}"></ques>

<ques [card_title]="'Xyz'" [card_text]="'What is Time'" [items]="{{items}}"></ques>

"ques selector is from an external component which has items array". I am currently in app module where i have imported the ques component and now i need to pass an array to the ques!

What currently works is

FileName: app.component.html

<ques [card_title]="'Abc'" [card_text]="'What is Space'" [items]="['google','stack','overflow']"></ques>

Any one have an idea about how to achieve this? I am a newbie and all suggestions and different approaches will be welcomed. Thanks!

Community
  • 1
  • 1
3rdi
  • 475
  • 4
  • 12

1 Answers1

6

this line

<ques [card_title]="'Xyz'" [card_text]="'What is Time'" 
                  [items] = "{{items}}"

should be like this

//items array in you ts file 
items:string[] = ['google','stack','overflow']";

//template 
<ques [card_title]="'Xyz'" [card_text]="'What is Time'" 
                  [items] = "items"

no need of {{items}} as you are already having []which is for inputting value from ts file variable

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263