I am new to angular.js and I'm having an issue with converting string into array and displaying it with ng-repeat, so far i got this custom filter from a stackoverflow question and the codes are:
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>
My problem is, it converts and display properly if it is an alphabet(abc) or a number(123) alone, and if combined (abc123) or (123abc) still good, but if the data is number+alphabet+number (123abc123) it doesnt show anymore in ng-repeat. I am really lost and really need help. Hope someone can lend me an answer.
123abc123to be split into an array and show up in your ng-repeat as123,abc,123?