@nullnillzero wrote:
All,
I'm new to ember and more familer with Angular/Angular2 than I am wit this framework. So far I like it but I can't seem to wrap my head around some of the terminology and design paradigms.I'm working on a project where I need to create a global class with persistence and can't quite figure out what the correct way to do this is.
Take the following plain javascript for example
// Pseudo code, untested, off the hip // UselessClass var UselessClass = { name: 'nullnillzero', setName: function(name) { this.name = name; }, getName: function() { return this.name; }, sayHello: function(name) { if(name === undefined) console.log('Hello ' + this.name); else console.log('Hello ' + name); } }
Then I could do something like this
// Pseudo code, untested, off the hip var myUselessClass = new UselessClass(); myUselessClass.sayHello('nullnillzero'); // Results in: console.log('Hello nullnillzero'); myUselessClass.setName('null'); // Results in settings null as name console.log(myUselessClass.getName()); // Results in console.log('null'); myUselessClass.sayHello(); // Results in console.log('Hello null');
How would I create a global class as shown in the first code block to be used globally in ember?
Posts: 2
Participants: 2