RonPringadi
RonPringadi

Reputation: 1494

How to pass parameters to an ember component?

I'm still new in ember js and currently using ember version 3.2.6.

I cannot seem to pass parameters to an ember component, what did I missed?

app/templates/application.hbs

<UserCard
  @userName='James123'
  @firstName='James'
  @lastName='Smith'
/>
<UserCard
  @userName='Jane123'
  @firstName='Jane'
  @lastName='Smith'
/>

app/components/user-card.hbs

<br/>
<strong>User Card</strong><br/>
<label>UserName: </label>{{userName}}<br/>
<label>First Name: </label>{{firstName}}<br/>
<label>Last Name: </label>{{lastName}}<br/>

Result

enter image description here

Upvotes: 0

Views: 636

Answers (1)

Gokul Kathirvel
Gokul Kathirvel

Reputation: 1610

The argument passed into an angle bracket component needs to be accessed using the @ keyword in the template.

app/components/user-card.hbs

<br/>
<strong>User Card</strong><br/>
<label>UserName: </label>{{@userName}}<br/>
<label>First Name: </label>{{@firstName}}<br/>
<label>Last Name: </label>{{@lastName}}<br/>

Upvotes: 2

Related Questions