Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs: ngSanitize is out ng core at AngularJS 1.2.21 #8519

Closed
wants to merge 1 commit into from

Conversation

juampynr
Copy link
Contributor

@juampynr juampynr commented Aug 7, 2014

When using ngBindHTML directive, ngSanitize module must be added as a dependency.

Not doing so results in the following error:

Error: [$sce:unsafe] http://errors.angularjs.org/1.2.21/$sce/unsafe
    at Error (native)
    at http://somesite/js/angular.min.js?n9wkqz:6:450
    at e (http://somesite/js/angular.min.js?n9wkqz:117:34)
    at getTrusted (http://somesite/js/angular.min.js?n9wkqz:118:327)
    at Object.e.(anonymous function) [as getTrustedHtml] (http://somesite/js/angular.min.js?n9wkqz:120:71)
    at Object.fn (http://somesite/js/angular.min.js?n9wkqz:192:234)
    at k.$digest (http://somesite/js/angular.min.js?n9wkqz:109:213)
    at k.$apply (http://somesite/js/angular.min.js?n9wkqz:112:173)
    at h (http://somesite/js/angular.min.js?n9wkqz:72:300)
    at w (http://somesite/js/angular.min.js?n9wkqz:77:288) 

You can see that the API reference for ngBindHTML includes the module below:

selection_004

@caitp
Copy link
Contributor

caitp commented Aug 7, 2014

well, this isn't quite true --- you just need the value to be trusted (which the $sce api lets you do). I would rather we "suggest" that you include ngSanitize, because it's simpler.

IIRC we already do actually say this somewhere in the docs, but I can't recall where.

@juampynr
Copy link
Contributor Author

juampynr commented Aug 7, 2014

@caitp, how about now? I added a mention to use $sce as an alternative.

@@ -765,6 +763,11 @@ of `$sce.trustAsHtml(string)`. When bound to a plain string, the string is sanit
module is not loaded) and the bound expression evaluates to a value that is not trusted an
exception is thrown.

When using this directive you can either include `ngSanitize` in your module's dependencis (See the
example at the [ngBindHtml](https://code.angularjs.org/1.2.21/docs/api/ng/directive/ngBindHtml) reference)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't link to a specific version of the doc (use the default revision like you used below)

@juampynr
Copy link
Contributor Author

juampynr commented Aug 7, 2014

Done!

@@ -765,6 +763,11 @@ of `$sce.trustAsHtml(string)`. When bound to a plain string, the string is sanit
module is not loaded) and the bound expression evaluates to a value that is not trusted an
exception is thrown.

When using this directive you can either include `ngSanitize` in your module's dependencis (See the
example at the [ngBindHtml](https://docs.angularjs.org/api/ng/directive/ngBindHtml) reference)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the links can and should be {@link ngBindHtml} and {@link $sce}. But please check by running grunt docs before changing

@caitp
Copy link
Contributor

caitp commented Aug 7, 2014

yeah petes right. For some reason I thought this was one of the markdown files in the root of the tree, but it's processed markdown so we use dgeni's link tag instead

@petebacondarwin
Copy link
Contributor

Other than that it LGTM

When using ngBindHTML directive, either ngSanitize or $sce must be used
or this will end in a non-trusted value error.
@juampynr
Copy link
Contributor Author

juampynr commented Aug 8, 2014

Done. Reviewed with grunt docs and got no errors.

@caitp
Copy link
Contributor

caitp commented Aug 8, 2014

the links look okay to me, I'm gonna merge it. @matsko the CSS for links looks really kinda bad though, they're really hard to identify as clickable :(

caitp pushed a commit that referenced this pull request Aug 8, 2014
When using ngBindHTML directive, either ngSanitize or $sce must be used
or this will end in a non-trusted value error.

Closes #8519
@caitp caitp closed this in 07d5283 Aug 8, 2014
@juampynr juampynr deleted the patch-2 branch August 8, 2014 01:15
@caitp
Copy link
Contributor

caitp commented Aug 8, 2014

@petebacondarwin / @juliemr are the v1.2.x failures flakes, or did something get checked in that broke them? they've been failing pretty consistently since I checked in this patch

@petebacondarwin
Copy link
Contributor

It seems weird. I would say flake since the changes were minimal but the
errors don't look like flakes...

On 8 August 2014 05:54, Caitlin Potter [email protected] wrote:

@petebacondarwin https://github.com/petebacondarwin / @juliemr
https://github.com/juliemr are the v1.2.x failures flakes, or did
something get checked in that broke them? they've been failing pretty
consistently since I checked in this patch


Reply to this email directly or view it on GitHub
#8519 (comment).

@caitp
Copy link
Contributor

caitp commented Aug 8, 2014

i don't think the failures are caused by this commit, but i expect they're legitimate

@juampynr
Copy link
Contributor Author

juampynr commented Aug 8, 2014

Hah! first commit into AngularJS and I break it ;D

Just kidding. Let me know if I can help debugging what's broken.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants