3
我想添加一個http請求頭到jqueryui自動完成請求。我查看了jQuery網站上的文檔,並在那裏介紹瞭解決方案以獲取Ajax請求。我認爲解決方案在我的情況下是類似的,但我不能讓這件事情起作用。如何將標題添加到jqueryui自動完成調用?
這是我的代碼。它包裹在一個angularjs中,但是在「link」方法中的調用不會在指令內部。
app.directive("buildingSearch", function() {
// I bind the $scope to the DOM behaviors.
function link(scope, element, attributes, controllers) {
//Attach the autocomplete functionto the element
element.autocomplete({
source: 'api/building/unitOrgMdl',
minLength: 2,
//*********
//This is the addition I made as per the jquery documentation that I figured would work but doesn't
headers: {
'Authorization': '122222222222'
},
//*********
select: function (event, ui) {
element.val(ui.item.label);
element.blur();
scope.getbuildings({ data: ui.item })
return false;
}
});
}
// Return the directive confirugation.
return ({
link: link,
restrict: "EA",
replace: true,
scope: {
getbuildings: '&'
}
});
});