Emberjs Creating a Class

Source: Internet
Author: User

Create a Person class
Person = Ember.Object.extend ({ function (thing) { alert (thing);}});

Create a person object that is an instance of the person class
var person = person.create ();p Erson.say ("Hello//Alerts" Hello "  
When you create an instance, you can also add additional properties to the instance by passing in the object
 var tom = person.create ({name: " tom dalehelloworld: function () {this.say ( "hi my name is " + this.get ( ' name //alerts "Hi My name is Tom Dale" 

When you create a new instance of an object, you can also override any properties and methods defined in the class
var yehuda = Person.create ({name:  "yehuda katz" say:  function (thing) {var name = this.get (namethis._super (name +    Says:  ; //            You can use the object's _super method (which super is a reserved word in JavaScript) to invoke the original method that you overwrite
} });
 < Span class= "local-variable" > < Span class= "delimiter" >  you can also use the  extend  method to create subclasses of classes. In fact, when we created the new class using the  extend  method of the  Ember.object  object above, the  subclass of  Ember.object  was created . 
/span>
var Loudperson = person.extend ({  function (thing) {    this._super (Thing.touppercase ());  }}); 

Emberjs Creating a Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.