I have a filter in AngularJS but when I try to represent value in the view with this filter, I get undefined x.
My code:
.filter('param', function() {
return function(x) {
console.log(x);
return x.split('__')[0];
};
})
view
{{value | param}}
Result
angular.js:13920 TypeError: Cannot read property 'split' of undefined
I suspect it is that when loading the page I still do not have the value because it is obtained from a promise.
value? Can you share it here ?undefined, and you cannot run.spliton undefined. Just do a check in your filter:if(!x) return x