javascript - How can I invoke encodeURIComponent from angularJS template? -
i have block in angular js template la
<a href="#/foos/{{foo.id}}">{{foo.name}}</a>
however, foo.id property can contain funky characters ('/'). want this:
<a href="#/foos/{{encodeuricomponent(foo.id)}}">{{foo.name}}</a>
but doens't work? how can fix this?
you create filter calls encodeuricomponent
e.g.
var app = angular.module('app', []); app.filter('encodeuricomponent', function() { return window.encodeuricomponent; });
then do
<a href="#/foos/{{foo.id | encodeuricomponent}}">{{foo.name}}</a>
running example: http://jsfiddle.net/yapdk/
Comments
Post a Comment