Angular报错:Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context.

Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context. http://errors.angularjs.org/1.3.15/$sce/unsafe at REGEX_STRING_REGEXP

完整异常信息如下:

Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context.
http://errors.angularjs.org/1.3.15/$sce/unsafe
    at REGEX_STRING_REGEXP (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:63:12)
    at htmlSanitizer (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:15142:13)
    at getTrusted (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:15306:16)
    at Object.$get.sce.(anonymous function) [as getTrustedHtml] (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:15986:16)
    at Object.ngBindHtmlWatchAction [as fn] (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:20593:29)
    at Scope.$get.Scope.$digest (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:14308:29)
    at Scope.$get.Scope.$apply (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:14571:24)
    at HTMLButtonElement.<anonymous> (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:21571:23)
    at HTMLButtonElement.eventHandler (http://localhost:63342/angular_train/static/js/angular-1.3.15/angular.js:3032:21)

原因:创建模块时,没有显示引入模块ngSanitize,解决办法如下:
var myApp=angular.module(‘myApp’, [‘angular-growl’,’ngSanitize’]);

the end

标签: angular
热门文章