I have this collection of courses:
[{ id: 1, courseId: 2, text: \'John\' },
{ id: 2, courseId: 2, text: \'Willi\' },
{ id: 3, courseId: 2, text: \'Inga\' },
I have created a filter in angularJs project.
in my angular app name is angularApp.
var app = angular.module('angularApp', []); // This is your main angular app.
Now you want to create a filter for decode url.
app.filter('decodeURL', function() {
return function(text) {
if(text) {
return text.split(' ').join('-').toLowerCase().replace(/[^a-z0-9]+/g, '-');
}
}
});
The above code is to create a filter to decode url. And my filter name is 'decodeURL' . we will use decodeURL as a filter in my code like if your URL is-
http://www.example.com/test1 test2 tes3
then filter make the URL like this-
http://www.example.com/test1-test2-tes3
How to use this filter in the html-
// The above is for state routing in angularjs.
Show
//The above code for URL redirecting.