Angular.JS 1.4 $ injector:尝试在我的应用程序中包含NgSanitize时出现模块错误

时间:2016-05-29 20:55:45

标签: angularjs ngsanitize

我一直在网上和本网站上查看解决方案,但无法弄清楚为什么在我的控制器中添加'ngSanitize'时,我的应用程序中出现了注射器模块错误。

https://jsfiddle.net/mxmqxos7/2/

    angular.module('mainapp', ['ngSanitize'])
      .controller('FormController', ['$scope','$sce' function($scope, $sce) {

         $scope.thisCanBeusedInsideNgBindHtml = $sce.trustAsHtml('<label>test123</label>');

        }]);

如果您需要更多详情,请通知我,我会提供。我在小提琴上加入了正确的CDN。

2 个答案:

答案 0 :(得分:0)

你的控制器阵列中的$ sce之后你缺少一个逗号。

将JSFiddle Load-type更改为head in head并且无效。

答案 1 :(得分:0)

这项工作:https://plnkr.co/edit/ZbBGKBOXRedN6NpboscU?p=preview

   var app = angular.module('mainapp', ['ngSanitize']);

   app.controller('FormController', function($scope, $sce) {

   $scope.thisCanBeusedInsideNgBindHtml = $sce.trustAsHtml('<label>test123</label>');

   });