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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -