Skip to content

Commit 4868cc1

Browse files
author
Florent Gouget
committed
make injector great again
1 parent 84cd5a9 commit 4868cc1

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

build/app.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,20 @@ function ActiveRecord(model, name) {
5353
function ActiveRecord($injector, rootUrl, options) {
5454
_classCallCheck(this, ActiveRecord);
5555

56-
this.$injector = $injector;
57-
this.rootUrl = rootUrl;
56+
//this.$injector = $injector;
57+
Object.defineProperty(this, '$injector', {
58+
get: function get() {
59+
return $injector;
60+
},
61+
enumerable: false
62+
});
63+
Object.defineProperty(this, 'rootUrl', {
64+
get: function get() {
65+
return rootUrl;
66+
},
67+
enumerable: false
68+
});
69+
5870
this.build(options);
5971
}
6072

@@ -405,19 +417,11 @@ function ActiveRecord(model, name) {
405417
}
406418
}
407419
});
408-
var $q = this._injector.get('$q');
420+
var $q = this.$injector.get('$q');
409421
return $q.all(promises).then(function () {
410422
return _this5.save(populate);
411423
});
412424
}
413-
}, {
414-
key: '$injector',
415-
get: function get() {
416-
return this._injector;
417-
},
418-
set: function set($injector) {
419-
this._injector = $injector;
420-
}
421425
}, {
422426
key: '$http',
423427
get: function get() {

dest/temp/ActiveRecord.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,20 @@ function ActiveRecord(model, name) {
5252
function ActiveRecord($injector, rootUrl, options) {
5353
_classCallCheck(this, ActiveRecord);
5454

55-
this.$injector = $injector;
56-
this.rootUrl = rootUrl;
55+
//this.$injector = $injector;
56+
Object.defineProperty(this, '$injector', {
57+
get: function get() {
58+
return $injector;
59+
},
60+
enumerable: false
61+
});
62+
Object.defineProperty(this, 'rootUrl', {
63+
get: function get() {
64+
return rootUrl;
65+
},
66+
enumerable: false
67+
});
68+
5769
this.build(options);
5870
}
5971

@@ -404,19 +416,11 @@ function ActiveRecord(model, name) {
404416
}
405417
}
406418
});
407-
var $q = this._injector.get('$q');
419+
var $q = this.$injector.get('$q');
408420
return $q.all(promises).then(function () {
409421
return _this5.save(populate);
410422
});
411423
}
412-
}, {
413-
key: '$injector',
414-
get: function get() {
415-
return this._injector;
416-
},
417-
set: function set($injector) {
418-
this._injector = $injector;
419-
}
420424
}, {
421425
key: '$http',
422426
get: function get() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "flogou <florent.gouget@gmail.com>",
33
"name": "angular-orm",
4-
"version": "2.0.5",
4+
"version": "2.0.6",
55
"description": "",
66
"homepage": "",
77
"dependencies": {

src/ActiveRecord.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ export default function ActiveRecord (model, name, SManager = SessionManager(mod
2020

2121
let ActiveRecord = class {
2222
constructor ($injector, rootUrl, options) {
23-
this.$injector = $injector;
24-
this.rootUrl = rootUrl;
23+
Object.defineProperty(this, '$injector', {
24+
get: function(){return $injector},
25+
enumerable: false
26+
})
27+
Object.defineProperty(this, 'rootUrl', {
28+
get: function(){return rootUrl},
29+
enumerable: false
30+
})
2531
this.build(options);
2632
}
2733

@@ -135,14 +141,6 @@ export default function ActiveRecord (model, name, SManager = SessionManager(mod
135141
return clone
136142
}
137143

138-
get $injector () {
139-
return this._injector;
140-
}
141-
142-
set $injector ($injector) {
143-
this._injector = $injector;
144-
}
145-
146144
get $http () {
147145
return this.$injector.get('$http');
148146
}
@@ -342,7 +340,7 @@ export default function ActiveRecord (model, name, SManager = SessionManager(mod
342340
}
343341
}
344342
})
345-
var $q = this._injector.get('$q')
343+
var $q = this.$injector.get('$q')
346344
return $q.all(promises).then(() => {
347345
return this.save(populate)
348346
})

0 commit comments

Comments
 (0)