0
獲取API的名字,我有一個角指令如何angularjs指令
mainApplicationModule
.directive('usSpinner2', ['$http', '$rootScope','$location','$state', function($http, $rootScope,$location,$state) {
return {
link: function(scope, elm, attrs) {
$rootScope.spinnerActive = false;
scope.isLoading = function() {
return $http.pendingRequests.length > 0;
};
scope.$watch(scope.isLoading, function(loading) {
$rootScope.spinnerActive = loading;
if (loading) {
elm.removeClass('ng-hide');
} else {
elm.addClass('ng-hide');
}
});
}
};
}])
,當我使用$ HTTP服務微調開始對服務器請求,並在響應到達客戶端停止。
我在客戶端
$http.get(baseUrl+'filename/apiname').success(function(res,req){
//code
})
使用這樣的$ HTTP服務在服務器端filename.js
router.get('/apiname',function(req,res){
//code
})
我想這是在要求對服務器數據當前apiname上面的指令。找了幾個小時後我找不到答案。我該怎麼做呢?
您的解決方案不工作我得到的不確定 – AMahajan
誤差不能讀取屬性「URL」請一次粘貼您最新的代碼。檢查演示鏈接。打開控制檯併發出JSON請求並單擊提取。 – Sravan
抱歉,我在錯誤的地方粘貼了主線。有效。謝謝 – AMahajan