How can I check if an angular model is an array or an object? Is there a built in or do I have to write a filter isArray
with Array.isArray()
{{[] | isA
You can use the angular.isArray
function. It's built-in inside Angularjs.
If you want to use this function inside your template, you have to create a custom filter: http://docs.angularjs.org/tutorial/step_09
Example of what you want:
angular.module('...', []).filter('isArray', function() {
return function (input) {
return angular.isArray(input);
};
});
Then you can use the filter inside your template:
{{ myVar | isArray }}