私は+ +6のコードを学習しています。angular.js:13550 TypeError: 'people'が未定義のプロパティ 'people'を設定できません
test.controller.js
class TestSecIndexController {
constructor (TestSecService,$q) {
this.src = require('./../images/2.jpg');
this._TestSecService = TestSecService;
let promises = [
this.getPeopleList()
];
$q.all(promises).then(function(){
console.log(this.people);
})
}
getPeopleList(){
return this._TestSecService.getPeopleList().then(function(res){
this.people = res.data; //line: 22
});
}
static testSecIndexController(TestSecService,$q){
return new TestSecIndexController(TestSecService,$q);
}
}
TestSecIndexController.testSecIndexController.$inject = ['TestSecService','$q'];
export default angular.module ('test2.index.controller', [])
.controller ('testSecIndexController', TestSecIndexController.testSecIndexController)
これを行う場合は、エラーがあります。なぜthis.people
ができない
angular.js:13550 TypeError: Cannot set property 'people' of undefined at index.controller.js:22
this.src
は、正常に設定できますか?
ありがとう!私は文脈について考えなかった – mqliutie