While working in Angular, I attempted to utilize a filter to replace certain strings with different words. Despite trying numerous examples, it seems like my code is missing something crucial that I can't seem to pinpoint. Here's the snippet of my code:
This is from my app.js file
app.filter('filterStatus', function () {
return function (text) {
if(text == 1){
return str = text.replace(/1/g, "Waiting");
} else if (text == 2) {
return str = text.replace(/2/g, "On Process");
} else if (text == 3) {
return str = text.replace(/3/g, "On The Way");
} else if (text == 4) {
return str = text.replace(/4/g, "Delivered");
} else if (text == 5) {
return str = text.replace(/5/g, "Expired");
}
};
});
I intended to swap out "1" with "Waiting" word, and below is an excerpt from my HTML page
<tr ng-repeat-start="siheaders in singleID.siheader">
<td>{{siheaders.status | filterStatus}}</td>
</tr>
However, upon debugging using firebug, I encountered the error message "Error: text.replace is not a function". What could I have overlooked in my implementation?