AngularJS

How display each element of a split string in a separate div

Supposing we have a long string with a list of items separated by some symbol, let`s say ‘|’:

longString = “one|two|three|four”

The task is to display each element of the longString in a separate div.

In order to do this, we can use ng-repeat directive in combination with the string split method:

<div ng-repeat="element in longString.split('|')">{{element}}</div>