小编Rah*_*hah的帖子

Angular 指令:来自其他文件的模板

如何在 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

javascript angularjs angularjs-directive

3
推荐指数
1
解决办法
2859
查看次数

AngularJS 向 $http.get 添加一个标头

我正在尝试添加包含用于未来 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)

javascript httprequest angularjs

2
推荐指数
1
解决办法
8068
查看次数