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

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}}


{{/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.

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

I’m having a hard time understanding the question.

So basically I have an array in the model called teacherPayees and for each element in the array I am rendering a form with the fields age and id correct.

Now in that child component i.e. detailed-teacher-info I want to access all the values of the model on init which is what my setup function is doing. The question is how do I do that? I am able to get the whole array in the js file by doing this this.get(‘model.teacher.teacherPayees’) but I just want the value of teacherPayees array that the current component is rendering.

So it sounds like you’re describing something like this:

{{#each teacherPayees as |teacherPayee|}}
  {{x-component teacherPayee=teacherPayee teacherPayees=teacherPayees}}

Components will not have the attributes in the init lifecycle hook. You likely want to start accessing attributes via didReceiveAttrs.