Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ng-bind-html for scope variable injection #4

Merged
merged 1 commit into from
Oct 27, 2014

Conversation

epigos
Copy link
Contributor

@epigos epigos commented Oct 24, 2014

I have a custom AngularJs template tags ({$ $}) in my project so the injection of the scope variable ngNotify.notifyMessage do not work. This also prevent rendering html in the notification message.

line 64 in ng-notify.js:

var tpl = $compile(
                '<div class="ngn" ng-class="ngNotify.notifyClass">' +
                    '<span class="ngn-dismiss" ng-click="dismiss()">&times;</span>' +
                    '<span>{{ ngNotify.notifyMessage  }}</span>' +
                '</div>'
            )(notifyScope);

I suggest it should be this way rather.

var tpl = $compile(
                '<div class="ngn" ng-class="ngNotify.notifyClass">' +
                    '<span class="ngn-dismiss" ng-click="dismiss()">&times;</span>' +
                    '<span ng-bind-html="ngNotify.notifyMessage"></span>' +
                '</div>'
            )(notifyScope);

This will prevent conflict with other templating language.

@matowens
Copy link
Owner

Great suggestion @epigos, much appreciated.

matowens added a commit that referenced this pull request Oct 27, 2014
use ng-bind-html for scope variable injection
@matowens matowens merged commit b369b1f into matowens:master Oct 27, 2014
@epigos
Copy link
Contributor Author

epigos commented Oct 27, 2014

Thanks @matowens

matowens added a commit that referenced this pull request Dec 16, 2014
…on ng-sanitize being added to the project. no need for that as a dependency.
@matowens
Copy link
Owner

Hey @epigos - just an FYI, I replaced ng-bind-html with ng-bind here. ng-bind-html requires ng-sanitize as a dependency where ng-bind doesn't require anything extra. It should do just as well here since we're dealing with text notices, unless you've got some HTML you're adding to your output. Just wanted to let you know, but definitely thank you for the insight there.

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

Successfully merging this pull request may close these issues.

2 participants