0
未知提供商:freeCodeCamperServiceProvider < - freeCodeCamperService我試圖重構我的角碼根據約翰爸爸的風格指南 - 我得到一個未知的注射器錯誤 - 未知提供商
angular
.module('plunker')
.factory('freeCodeCamperService', freeCodeCamperService);
freeCodeCamperService.$inject = ['$http'];
function freeCodeCamperService($http){
var service ={
getPostsRequest: getPostsRequest,
getPostsResponse: getPostsResponse
};
return service;
// 2F4F4F
function getPostsRequest(){
return $http.get('http://www.freecodecamp.com/news/hot').then(getPostsResponse);
}
function getPostsResponse(response){
modifyDate(response);
return response;
}
function modifyDate(response){
for(var i=0; i<response.data.length; i++){
response.data[i].timePosted=new Date(response.data[i].timePosted).toDateString();
}
}
}
這裏是鏈接到我的plunker - http://plnkr.co/edit/Fw5ko4kafIg9r1KzZwA3