Javascript 对变量使用脚本标记时发生角度清理抛出错误

Javascript 对变量使用脚本标记时发生角度清理抛出错误,javascript,angularjs,angular-sanitizer,Javascript,Angularjs,Angular Sanitizer,正在尝试使用angular sanitizer在我的应用程序上实现angular sanitizer,但它没有按预期工作 angular.module'sanitizeExample',['ngSanitize'] .controller'ExampleController',['$scope','$sce',函数$scope,$sce{ //$scope.snippet=alert1; $scope.snippet=alert1; $scope.delatelyTrustDangerousS

正在尝试使用angular sanitizer在我的应用程序上实现angular sanitizer,但它没有按预期工作

angular.module'sanitizeExample',['ngSanitize'] .controller'ExampleController',['$scope','$sce',函数$scope,$sce{ //$scope.snippet=alert1; $scope.snippet=alert1; $scope.delatelyTrustDangerousSnippet=函数{ 返回$sce.trustAsHtml$scope.snippet; }; $scope.escape=functioninput{ 返回$sce.trustAsHtmlinput; } }]; 片段: 指示 怎样 来源 提供 ng绑定html 自动使用$sanitize ng绑定html 通过明确信任危险值绕过$sanitize ng绑定 自动逃逸 ggg {{escapealert1}

这样行吗

angular.ModulesInitiatizeExample,['ngSanitize'] .controllerExampleController,['$scope','$sce',函数$scope,$sce{ /*$scope.snippet=alert1*/ $scope.snippet=alert1; $scope.delatelyTrustDangerousSnippet=函数{ 返回$sce.trustAsHtml$scope.snippet; }; $scope.escape=functioninput{ 返回$sce.trustAsHtmlinput; } }]; 片段: 指示 怎样 来源 提供 ng绑定html 自动使用$sanitize ng绑定html 通过明确信任危险值绕过$sanitize ng绑定 自动逃逸 ggg {{escapealert1}


仅包含足以从视图中执行清理的ngSanitize模块

这不是从视图测试消毒的正确方法。它作为变量传递给angular,以便执行并发出警报


当我们从数据服务进行测试时,sanitize按预期工作

看一看我正在寻找xss攻击清理修复程序。我的要求是在html模板中也将脚本显示为文本。
angular.module("sanitizeExample", ['ngSanitize'])
{{ escape("<script type='text/javascript'>alert(1)</script>") }}