現在我試圖顯示從服務到controller..When我想顯示錯誤的不低於working.The返回的響應是,我試圖如何在服務向角控js中的控制器返回錯誤後在頁面上顯示錯誤?
var app=angular.module('httpExample',[]);
app.controller("FetchController",["$scope","clickevent",function($scope,clickevent){
clickevent.fetch().then(function(response){
$scope.req=response;
console.log(angular.toJson(response));
}).error(function(error){
console.log(error);
});
}]);
app.service("clickevent",['$http',function($http){
var clickevent={
fetch:function(){
var prom=$http({method:"GET",url:"http://www.w3schools.com/angular/customers.php"}).
success(function(response){
return response;
}).
error(function(err){
return err;
});
return prom;
}
};
return clickevent;
}]);
您有拼寫錯誤'function'本着'})錯誤(溫控功能(錯誤){'(6號線) – Nalaka526
樂施會sorry..Even但其'clickevent.fetch'中沒有給出任何錯誤 –
返回承諾? – Jorg