I am a beginner in angular.js and I'm facing an issue with converting a string into an array and displaying it using ng-repeat. I found a custom filter from a stackoverflow question and here are the codes:
JS:
var app = angular.module('globalModule', [])
app.controller("SampleController", function($scope){
$scope.data = "123abc123";
});
app.filter("spaceBreak",
function () {
return function ( value ) {
if( !value.length ) return;
return value.split("");
}
});
HTML:
<body ng-controller="SampleController">
<h4 id="id_{{$index}}" ng-repeat="value in data | spaceBreak"><span ng-bind="value"></span></h4>
</body>
The problem I'm facing is that it converts and displays properly if it's just alphabets (abc) or numbers (123) alone, or combined like (abc123) or (123abc). However, when the data is in the format of number+alphabet+number (123abc123), it doesn't show up anymore in ng-repeat. I'm quite lost and really need some help. Hopefully, someone can provide me with a solution.