🔄 A simple Angular filter to URL-encode or decode a string using encodeURI
and decodeURI.
Comments and Pull Requests welcome!
- AngularJS (^1.4.0)
$ npm install angular-url-encode --S$ bower install angular-url-encode --SAdd the script and styles to your HTML:
<script src="../path/to/angular-url-encode/dist/angular-url-encode.js"></script>Add bc.AngularUrlEncode to your module's dependencies:
angular.module('myModule', ['bc.AngularUrlEncode']);As a filter in the DOM:
<p>{{ myPlainString | bcEncode }}</p>
<p>{{ encodedString | bcDecode }}</p>Using the $filter service:
// Encode
this.encodedString = $filter('bcEncode')(this.myPlainString);
// Decode
this.decodedString = $filter('bcDecode')(this.encodedString);npm run build- produces production version of your library under thedistfoldernpm run dev- produces development version of your library and runs a watcher