jeudi 6 juin 2019

Data corrupted when sending from template to component lifecycle method?

EMBER VERSION 3.10

DESCRIPTION

If I pass an array of objects from a template(after iterating the array in the template view) to a component and try to access the data in one of the lifecycle methods of the component. The data is corrupted.

CODE

controllers/application.js

import Ember from 'ember';

export default Ember.Controller.extend({
  users: [{name:1},{name:2},{name:3}]
});

templates/application.hbs


  <p></p>


<FilterUsers @users= />


templates/components/filter-users.hbs

empty file

components/filter-users.js

import Ember from 'ember';
export default Ember.Component.extend({
  init(){
    this._super(...arguments);
    console.log(this.get('users'));
  }
});

OUTPUT

with bug

enter image description here

without bug

If i removed each block from application.hbs which iterates the array. I get proper results.

templates/application.hbs

<FilterUsers @users= />


enter image description here

I'm new to ember, so is it a bug or am i not doing the ember way ?




Aucun commentaire:

Enregistrer un commentaire