import Component from '@glimmer/component';
import Ember from 'ember';
import EmberObject from '@ember/object';
import { action, without, set, get, computed }
from '@ember/object';
let value = 0;
const Student = EmberObject.extend({
fullName: computed('firstName', 'lastName', {
get() {
console.log(
'Computed property called for ',
this.firstName, value += 1
)
return `${this.firstName} ${this.lastName}`;
}
}),
toStringExtension() {
return this.get('fullName');
},
});
export default Ember.Component.extend({
students: [
Student.create({
firstName: 'Sam',
lastName: 'Snehil',
Marks: 72,
class: 11,
}),
Student.create({
firstName: 'Ram',
lastName: 'Sahu',
Marks: 84,
class: 10,
}),
Student.create({
firstName: 'Soham',
lastName: 'Verma',
Marks: 69,
class: 12,
}),
Student.create({
firstName: 'David',
lastName: 'Tigga',
Marks: 53,
class: 9,
}),
Student.create({
firstName: 'Pokhu',
lastName: 'Verma',
Marks: 95,
class: 10,
}),
Student.create({
firstName: 'Satyam',
lastName: 'Verma',
Marks: 75,
class: 12,
}),
],
@action
StoreName(data) {
this.students.forEach(function (item) {
if (item.fullName == data) {
let temp = item.cacheFor('fullName');
console.log(`${temp} is stored
from ${item.toString()}`)
}
})
}
})