自定义指令被阻止
Custom directive blocked
我定义了这样一个自定义指令:
.directive('row', [function() {
return {
restrict: 'E',
templateUrl: 'chrome://mailtowebmails/content/resources/directives/row.htm'
};
}])
但是当我尝试使用它时出现此错误:
”错误:[$sce:insecurl] $sceDelegate 策略不允许从 url 加载资源。URL: chrome://mailtowebmails/content/resources/directives/row.htm
尝试 0
我试过这样消毒:
.config( [
'$compileProvider',
function( $compileProvider )
{
$compileProvider.aHrefSanitizationWhitelist(/^\s*(filesystem:chrome):/);
}
])
但它并没有修复它。
这是一个插件,所以我的文件路径在文件系统上。
尝试 1
我也试过:
var ANG_APP = angular.module('mailtowebmails', [])
.config(['$sceDelegateProvider', function ($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', new RegExp('chrome')]);
}])
然后我收到这个错误:
Error: [$injector:modulerr] Failed to instantiate module mailtowebmails due to:
[$injector:modulerr] Failed to instantiate module $sceDelegateProvider due to:
[$injector:nomod] Module '$sceDelegateProvider' is not available! You either misspelled the module name or forgot to load it. If
尝试 2
我也按照@Tribute 的建议尝试了这个,但是没有用:
var ANG_APP = angular.module('mailtowebmails', [])
.directive('row', [function() {
return {
restrict: 'E',
templateUrl: 'chrome://mailtowebmails/content/resources/directives/row.htm'
};
}])
.controller('BodyController', ['$scope', '$sce', function($scope, $sce) {
$scope.trustSrc = function(src) {
return $sce.trustAsResourceUrl(src);
};
您 "Try 1" 的方法应该有效。但是必须更改正则表达式。
.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'chrome://mailtowebmails/**/*.html']);
}])
我定义了这样一个自定义指令:
.directive('row', [function() {
return {
restrict: 'E',
templateUrl: 'chrome://mailtowebmails/content/resources/directives/row.htm'
};
}])
但是当我尝试使用它时出现此错误:
”错误:[$sce:insecurl] $sceDelegate 策略不允许从 url 加载资源。URL: chrome://mailtowebmails/content/resources/directives/row.htm
尝试 0
我试过这样消毒:
.config( [
'$compileProvider',
function( $compileProvider )
{
$compileProvider.aHrefSanitizationWhitelist(/^\s*(filesystem:chrome):/);
}
])
但它并没有修复它。
这是一个插件,所以我的文件路径在文件系统上。
尝试 1
我也试过:
var ANG_APP = angular.module('mailtowebmails', [])
.config(['$sceDelegateProvider', function ($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', new RegExp('chrome')]);
}])
然后我收到这个错误:
Error: [$injector:modulerr] Failed to instantiate module mailtowebmails due to: [$injector:modulerr] Failed to instantiate module $sceDelegateProvider due to: [$injector:nomod] Module '$sceDelegateProvider' is not available! You either misspelled the module name or forgot to load it. If
尝试 2
我也按照@Tribute 的建议尝试了这个,但是没有用:
var ANG_APP = angular.module('mailtowebmails', [])
.directive('row', [function() {
return {
restrict: 'E',
templateUrl: 'chrome://mailtowebmails/content/resources/directives/row.htm'
};
}])
.controller('BodyController', ['$scope', '$sce', function($scope, $sce) {
$scope.trustSrc = function(src) {
return $sce.trustAsResourceUrl(src);
};
您 "Try 1" 的方法应该有效。但是必须更改正则表达式。
.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'chrome://mailtowebmails/**/*.html']);
}])