Split for ng repeat item?

前端 未结 3 900
一生所求
一生所求 2021-02-20 04:18

Simple question- if I have this in my controller:

$scope.somedata = \'Item 1, Item 2\'; // set from something else

is there a way to split some

3条回答
  •  旧巷少年郎
    2021-02-20 05:11

    commented delimiter here

    angular.module('myFilters', []).
      filter('split', function() {
        return function(input, delimiter) {
          //var delimiter = delimiter || ',';
    
          return input.split(delimiter);
        } 
      });
    

    You could use the filter like so: also added track by $index to avoid crash due to duplicate values

提交回复
热议问题