Introduction
Defaults, Initialize etc are native methods of Model.Models can also contain as many custom methods as you like to manipulate attributes. By default all methods are public.
Solution
Modify Model code to add following custom method
changeName: function(newName){this.set('name', newName)}
Using following code instantiate model and check console.
var person = new human;
console.log(person.get('name'));
person.changeName('Technolodge');
console.log(person.get('name'));
Defaults, Initialize etc are native methods of Model.Models can also contain as many custom methods as you like to manipulate attributes. By default all methods are public.
Solution
Modify Model code to add following custom method
changeName: function(newName){this.set('name', newName)}
Using following code instantiate model and check console.
var person = new human;
console.log(person.get('name'));
person.changeName('Technolodge');
console.log(person.get('name'));
No comments:
Post a Comment