如何拆分字符串angularjs n次

时间:2015-10-28 12:51:45

标签: angularjs split

我正在使用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

出现的次数可能不同

1 个答案:

答案 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("");