Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4829

How to get value of model in the component for the element of the model array it is accessing?

$
0
0

@gjhawar wrote:

I have a parent component that renders a child component for each element in the model`s array like :

{{#each model.teachers.teacherPayees as |teacherPayee|}}

{{#detailed-teacher-info teacherPayee=teacherPayee model=model}}

Separation


{{/detailed-teacher-info}}

{{/if}}
{{/each}}

Now the problem is in the detailed-teacher-info component I want to know which elements it is referring to, the model is like

  teacher : {
	"name" : "teacher1",
	 "teacherPayees" : [
	     {"age" : 21, id : 1}, 
	     {"age" : 41, id : 2}
	 ]}

So, component1 should be referring to teacherPayees where age is 21.

In my component js when I do

	 setup: function() {
let teacherPayees = this.get('teacherPayee'); //Is a store which has age and id as computed property.
console.log(teacherPayees.age); //Is a computed property - How do I get the value for it
console.log(this.get('model.teacher.teacherPayees')); // This has the array but how would I know which element is this component using.
}.on('init')

So, the problem is how do I know which model element of the array the current component is referring to.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles