Objects in javascript

3

When working with objects in javascript, and with the AngularJS framework, where should we write the object code?

For example, I'm going to create an object with something like this:

var LogMessage = function(system, type, message, value, now) {
    this.system = system;
    this.type = type;
    this.message = message;
    this.value = value;
    this.time = now;
};

If I need to use it on several services or controllers, I would have to copy the code to all places, so should I create a js file that has all my objects?

    
asked by anonymous 10.05.2016 / 14:42

1 answer

0

What you can do is create it in a JS file that is loaded before all others, and always loaded as well. So you can always use it. Ex:

link

    
10.05.2016 / 14:50