4

I´m playing with angular.js and try to learn ng-bind and ng-bind-html.

First, my code:

<div ng-app="module" ng-controller="controller as ctrl">
<div ng-bind-html="ctrl.html"></div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js"></script>

<script>
var themodule = angular.module("module", ["ngSanitize"]);
themodule.controller("controller", [function()
{
this.html = "<strong>Hello</strong><div>More</div>";
}
]);
</script>

Even when it works, in the console appears the following ERROR:

Error: c.push is not a function
yc/this.$get</D.$$addBindingInfo<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:73:319
$d</<.compile/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:214:329
$@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:70:197
B@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:59:255
g@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:51:335
B@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:59:199
g@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:51:335
D/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:50:444
uc/d/</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:18:4
Pe/this.$get</n.prototype.$eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:126:11
Pe/this.$get</n.prototype.$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:126:236
uc/d/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:17:477
e@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:36:313
uc/d@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:17:1
uc@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:18:179
Jd@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:17:1
@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:250:429
a@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:164:283
lf/c@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:32:384
 <div class="ng-binding" ng-bind-html="ctrl.html">

I searched but I could not find anything about it.

Does anyone know WHY and HOW to resolve it?

Thanks!

2
  • 1
    Try use the right version of ng-sanitize i.e <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-sanitize.js". Your angular core version and sanitize versions do not match Commented Nov 4, 2015 at 20:22
  • 1
    @PSL Thanks a lot! BIG lesson learned! Commented Nov 4, 2015 at 20:27

1 Answer 1

2

try to use this version of angular-sanitize.js

src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-sanitize.js"

OR

src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-sanitize.js"

and use

var app = angular.module("myFirstApp", ['ngSanitize']);/*"angular-sanitize.js",
which has functions for removing potentially dangerous tokens from the HTML.*/

I hope your problem will be resolved.

Sign up to request clarification or add additional context in comments.

2 Comments

what do you want to say?
format your contents, its easy to write contents. But make it attractive, it plays crucial role in stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.