import Component from '@glimmer/component' ;
import { tracked } from '@glimmer/tracking' ;
import { action } from '@ember/object' ;
import Ember from 'ember' ;
let Student = Ember.Object.extend({
firstName: null ,
lastName: null ,
init() {
alert(`${ this .get( 'firstName' )} is Listed`);
},
fullName: Ember.computed( 'firstName' , 'lastName' , function () {
return `${ this .firstName} ${ this .lastName}`;
}),
Changed: Ember.observer( 'fullName' , function () {
console.log(`fullName changed to: ${ this .fullName}`);
}),
});
export default Ember.Component.extend({
students: [
Student.create({
firstName: 'Balit' ,
lastName: 'stark' ,
Id: 'stu2' ,
}),
Student.create({
firstName: 'Permu' ,
lastName: 'scott' ,
Id: 'stu0' ,
}),
Student.create({
firstName: 'Sam' ,
lastName: 'melo' ,
Id: 'stu1' ,
}),
Student.create({
firstName: 'Pokhu' ,
lastName: 'Verma' ,
Id: 'stu3' ,
}),
Student.create({
firstName: 'Tanu' ,
lastName: 'Agrawal' ,
Id: 'stu4' ,
}),
Student.create({
firstName: 'Arabh' ,
lastName: 'Singh' ,
Id: 'stu5' ,
})],
@tracked
item3: 'Gulshan' ,
@tracked
item2: 'Verma' ,
@tracked
item1: 'stu6' ,
@action
print(data1, data2, data3) {
let temp = Student.create({
firstName: data1,
lastName: data2,
Id: data3
});
this .students.addObject(temp);
}
})
|