如何在 angular js 中包含 .html 作为我的模板文件,而不是在模板属性中包含直接的 HTML 代码?`
到目前为止,这是我的代码:
.directive('navigation', ['$rootScope', '$i18next', function ($rootScope: any, $i18next: any) {
return {
bindToController: true,
template: '../views/navigation-directive.html',
link: function (scope, element, attrs) {....
Run Code Online (Sandbox Code Playgroud)
但是当运行此代码时,我的浏览器显示的唯一内容是以纯文本形式显示的“../views/navigation-directive.html”。
我的文件的当前结构是这样的。
指令文件位于 solution/script/navigation.js .html 文件位于 solution/view/navigation-directive.html
我正在尝试添加包含用于未来 HTTP 请求的令牌的“授权”标头。检索令牌似乎没问题,但是在发出 get 请求时失败并显示 Unauthorized 错误消息。检查请求标头后,请求块中不存在授权标头...
window.crUtil = /*window.crUtil ||*/ (function() {
// Angular Services
var $injector = angular.injector(['ng']);
var $http = $injector.get('$http');
// getting the CFF data
function get_data() {
getJWTAWS();
var url = '/AWS/getDATA/555';
console.log('AUTH header before call: ' + $http.defaults.headers.common.Authorization);
$http.get(url,httpHeader).then(function successCallback(response) {
var data = response.data;
var cff = initCff();
alert(data.itemId);
}, function errorCallback(response) {
initCff();
alert("Error while getting data ");
});
}
function getJWTAWS() {
var httpConfig = {
cache: true,
params: {}
}; …Run Code Online (Sandbox Code Playgroud)