0
私はes6でかなり新しいですが、私はしばらくの間角度をつけています。Babelがes6 angular factoryをコンパイルできませんでした
以下のコードがなぜBabelによって翻訳されないのかわかりません。 https://babeljs.io/に貼り付けて自分でテストしてください。
const singleDocumentSample
の先頭にある(
が間違って報告されたエラーのように見えるというエラーです。私は、それが初期化に関係していた場合のために、
const xx; xx = {};
を試してみました。 let
、さらにvar
に変更しようとしました。何が起こっている?
以下のコード全体のファイル:
class FakeData {
constructor($httpBackend) {
'ngInject';
this.$httpBackend = $httpBackend;
}
initialize() {
this.$httpBackend.whenGET('/v1/api/documents').respond(function() {
return [200, getAllDocuments()];
});
this.$httpBackend.whenGET(/\/v1\/api\/documents\/[1-9][0-9]*/).respond(function() {
return [200, getDocumentById()];
});
}
getAllDocuments() {
return allDocumentsSample;
}
getDocumentById() {
return singleDocumentSample;
}
const singleDocumentSample = {
"id": "5728fdb8e4b04adb356afb87",
"fileName": "6454841.xlsx",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"fileExtension": "xlsx",
"uploadDate": "2016-05-03T19:36:24Z",
"thumbnails": [
],
"thumbnailsDetailed": null,
"fileSize": 11467,
"description": "",
"position": null,
"confidential": null,
"customMetadata": null,
"who": {
"creationDate": "2016-05-03T19:36:24Z",
"lastUpdateDate": "2016-05-03T19:36:24Z",
"createdBy": {
"userName": "hawkslee",
"fullName": "Hawksley, Emma",
"userId": 49952
},
"lastUpdatedBy": {
"userName": "hawkslee",
"fullName": "Hawksley, Emma",
"userId": 49952
}
},
"url": "http://attachments-api.apps.wwt.com/api/attachments/5728fdb8e4b04adb356afb87/file"
};
const allDocumentsSample = {
"data": [
{
"id": "5728fdb8e4b04adb356afb87",
"fileName": "6454841.xlsx",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"fileExtension": "xlsx",
"uploadDate": "2016-05-03T19:36:24Z",
"thumbnails": [
],
"thumbnailsDetailed": null,
"fileSize": 11467,
"description": "",
"position": null,
"confidential": null,
"customMetadata": null,
"who": {
"creationDate": "2016-05-03T19:36:24Z",
"lastUpdateDate": "2016-05-03T19:36:24Z",
"createdBy": {
"userName": "hawkslee",
"fullName": "Hawksley, Emma",
"userId": 49952
},
"lastUpdatedBy": {
"userName": "hawkslee",
"fullName": "Hawksley, Emma",
"userId": 49952
}
},
"url": "http://attachments-api.apps.wwt.com/api/attachments/5728fdb8e4b04adb356afb87/file"
}
],
"pagination": {
"page": 1,
"pageSize": 50,
"pageCount": 456,
"sort": "id",
"order": "asc",
"itemCount": 22799,
"nextPageUrl": null,
"previousPageUrl": null
}
};
}
appModule.factory('fakeData', $httpBackend => new FakeData($httpBackend));