angular-activerecord
angular-activerecord copied to clipboard
Any example how to use it with ES6?
Is there a way to use angular-activerecord with es6?
BaseModel -> ChildModel ?
class ChildModel extends ActiveRecord
I'm having some problems with this. I would like to use Active Record in a service.
My code is the following:
import ActiveRecord from 'angular-activerecord';
class ExampleService extends ActiveRecord {
static factory(){
ExampleService.instance = new ExampleService();
return ExampleService.instance;
}
constructor() {
super();
}
ExampleService.factory.$inject = [];
export default ExampleService;
I get the following error : Error: (SystemJS) TypeError: Super expression must either be null or a function, not object(…)
A console.log(ActiveRecord); returns Object {}.
Could you provide an example how to correctly do this?
Thank you very much!
@isonet import ActiveRecord from 'angular-activerecord'; won't return the ActiveRecord constructor function.
I've made an attempt to convert to an UMD module so I could return the ActiveRecord constructor, but was unsuccessful because it conflicts with the angular 1 module system.
And switching to using ActiveRecord.$inject would change the constructor signature.
ES6 Usage:
import 'angular-activerecord';
angular.module('my-module').factory('ExampleService', ['ActiveRecord', function (ActiveRecord) {
class ExampleService extends ActiveRecord {
constructor(properties, options) {
super(properties, options);
}
}
ExampleService.instance = new ExampleService();
return ExampleService
}]);