I did common modal pop-up for one of the project. For that modal pop-up, I am passing data-model(say Salary model) as a parameter. Sometimes we need to pass model as an object (i.e. instead of salary model we pass salary object). Based on that i am checking if parameter is an instance of ember or an object .
My question is, can we convert object(say salary object) to ember data model (say salary model)?
For eg:- I have a Model like below
App.Salary=DS.Model.extend({
emp_name:DS.attr('string'),
emp_salary:DS.attr('string')
});
Json object
{salary:{id:1,emp_name:'Raju',emp_salary:'5000'}}
For some reasons , I pass ember salary model as an parameter / salary object(JSON) as an parameter
Both are having same data , but salary model will be ember instance . If i change some thing in node , it will reflect in associated models. But for salary object , if change some thing in node , it will not reflect in associated models .
I know salary object is not associated with ember-data model , that's why it will not reflect with salary associated models .
So is there any way to convert that salary object into salary model . So if i change something in the node , it will reflect associated models .
We can use
this.store.push(this.store.normalize('salary', {id:1,emp_name:'Raju',emp_salary:'5000'}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With