npm

Need private packages and team management tools?Check out npm Orgs. »

angular-sanitize-custom

1.3.1 • Public • Published

angular-sanitize-custom

(Based on angular-sanitize v1.6.9)

Add method `addValidElements` back to the old version(<1.6.10) of angular-sanitize.


History

I worked on a project that uses Angular version 1.6.9. In order to use ng-bind-html with custom tag without any errors, we must add all custom tags to the trust list. This method ONLY exists in angular-sanitize v1.6.10 or above, but NOT in v1.6.9 or below. Follow the requirements of my project, I can't upgrade any libraries and so I need to hack the original version and make it works on the custom tags.

Demonstration on CodePen

https://codepen.io/ssmak/pen/XYmEMO

Installation + Use

  1. Install to your project as dependency from NPM (https://www.npmjs.com/package/angular-sanitize-custom)
npm install angular-sanitize-custom --save
  1. Load the dependency
<script src="/node_modules/angular-sanitize-custom/angular-sanitize-custom.min.js"></script>
  1. Define the dependency to your Angular module
angular.module('myApp', ['ngSanitize']);
  1. Configure the provider and add any custom tags to the trust list
angular.module('myApp').config($sanitizeProvider => {
  $sanitizeProvider.addValidElements(['newElement1', 'newElement2']);
});

Test

A demo page is located in the /test folder. You can test with each version of angular-sanitize with the live reload by using lite-server which can be installed by

npm install lite-server -g
cd /project_root && lite-server

License

MIT

install

npm i angular-sanitize-custom

Downloadsweekly downloads

0

version

1.3.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability