I have created a custom JavaScript class:
var ExampleClass = new function(elements) {
this.elements = elements;
this.someFunction() {
// logic involving this.elements
};
};
How can I incorporate it into an Angular application? For instance, if I want to use it within a controller:
.controller('ExampleController', ['ExampleClass',
function (ExampleClass) {
var elements = [
{id: 1, label: 'foo'},
{id: 2, label: 'bar'}
];
$scope.exampleInstance = new ExampleClass(elements);
}])
What is the correct way to register my ExampleClass
? Are there multiple options available?
Moreover, is it considered problematic to utilize native JavaScript classes in an Angular application without fully integrating them into the framework?