我結束了這個指令 - 在工程 - 幫我的朋友丹尼斯我的情況。希望它可以幫助某人。
(function() {
'use strict';
angular
.module('app')
.directive('emediateScript', emediateScript);
/* @ngInject */
function emediateScript(Ad, $http) {
var directive = {
link: link,
restrict: 'E',
scope: {
ad: '=ad',
}
};
return directive;
function link(scope, element, attrs){
var _el = angular.element(element);
var url = 'http://www.http.com';
var request = {
method: 'GET',
url: url,
headers: {
'X-Authentication': undefined
}
};
if (url) {
$http(request).then(function(response) {
var html = response.data.substr(16);
html = html.substring(0, html.length - 4);
_el.html(html);
});
}
};
};
})();
而且HTML是;
<emediate-script></emediate-script>
您是否試圖在運行時注入腳本? –
是:) @RahilWazir – Tommy