我正在使用AngularJs。 我有一个字符串说:
$scope.myString = "hello stack. \n how are you? \n what do you need? \n blah blah blah";
我想在每次找到\ n时分割这个字符串。 所以输出(在我的html页面上)必须是:
hello stack
how are you?
what do you need?
blah blah blah
出现的次数可能不同
答案 0 :(得分:1)
$scope.myString = "hello stack. \n how are you? \n what do you need? \n blah blah blah";
var result = $scope.myString.split("\n").join("");