【发布时间】:2019-03-21 04:37:09
【问题描述】:
我想解决如何在我的 html 中使用$scope.time。
我想在 UI 中显示最后一次 http 请求的时间,但给了我一个错误。
我不能使用$scope。
我有这些代码:
module.factory('timestamp', [function ($scope) {
var time = {
request: function (config) {
$scope.time = new Date().getTime(); //wanted to show in UI realtime
return config;
}
//,response: function (response) {
// response.config.responseTimestamp = new Date().getTime();
// return response;
//}
};
return time;}];
配置:
module.config(function ($httpProvider) {
$httpProvider.interceptors.push('timestamp');}
【问题讨论】:
标签: angularjs httprequest interceptor