Open In App

How to Create Instances in Ember.js ?

Ember.js is an open-source javascript framework to build modern web applications. It allows developers to create a single-page web application that can reduce the workload of creating so many pages to do the same task. It is based on Model-View-Controller(MVC) used to develop large client-side web applications. Most of the developers find the easiest ways to do the tasks very easily and fastly so Ember.js helps most developers to save their time by reducing their workload and providing advanced facilities to build the single-page web application. 

Steps to create an instance in ember.js:






App.P1 = Ember.Object.extend({
  sayHi: function(x) {
    alert(x);
  }
});




App.P1View = Ember.View.extend({
  tag: 'hi',
  cNameBindings: ['isAdmin']
});




App.P1 = Ember.Object.extend({
  sayHi: function(x) {
    var name = this.get('name');
    alert(name + " says: " + x);
  }
});
  
App.S1 = App.P1.extend({
  sayHi: function(x) {
    this._super(x+ ", Done!");
  }
});
  
var fun1 = App.S1.create({
  y: "Harry Don"
});
  
fun1.sayHi("Ok");

Output:

alerts "Harry Don says: Ok, Done!"




var p = App.P1.create();
p.sayHi("Hi");

Output:



alerts " says: Hi"




App.P1 = Ember.Object.extend({
  hellofun: function() {
    alert("Hello world!! " + this.get('inp_name'));
  }
});
  
var harry = App.P1.create({
  inp_name: "Monty"
});
  
harry.hellofun();

Output:

alerts "Hello world!! Monty"

Limitations:


Article Tags :