我尝试过这样的事情,但收到错误:TypeError: Cannot read property 'split' of undefined
var myApp = angular.module('myApp', ['ui.router'])
.filter('newlines', function(){
return function(text){
return text.split('\n');
};
})
HTML:
<textarea class="form-control" rows="3" ng-model="numbers" ng-trim="true" placeholder="Numbers in one per line format" ng-repeat="n in numbers | newlines"></textarea>
答案 0 :(得分:-1)
您需要在数组中获得值。
filter('newlines', function(){
return function(text){
var array=[];
array=text.split('\n');
return array[0] // or if u want second part array[1]
};
})