I'm trying to implement base logic with classes in JavaScript using AngularJs. Here an example:
class Animal {
constructor($scope, service) {
'ngInject';
let vm = this;
vm.service = service;
service.getAll().then((result) => {
vm.animals = result;
});
}
}
class Rabbit extends Animal {
constructor($scope, $log, service) {
'ngInject';
super($scope, service);
let vm = this;
vm.save = save;
function save() {
service.add(vm.newAnimal).then((result) => {
vm.animals = result;
});
}
}
The problem is that changes from inherit class doesn't make sense for super.animals
and that object won't be updated as a result my view doesn't rerender list with objects. What's wrong with my code or logic?
Thanks in advance!