Search code examples
javascriptangularjsline-breaksnotepad

How to export string to text file with linebreak? AngularJS


I have function when you import a text file like this enter image description here

the date will be formatted to this enter image description here and it will automatically exports a notepad that contains the new formatted date

but the thing is the line break is not working the newly exported notepad is like this enter image description here

my code for the string is

   var fileText = $scope.list[0]+"\n"
      +$scope.list[1]+"\n"
      +$scope.list[2]+"\n"
      +$scope.list[3]+"\n"
      +$scope.list[4]+"\n"
      +$scope.list[5]+"\n"
      +$scope.list[6]+"\n"
      +$scope.list[7]+"\n"
      +$scope.list[8]+"\n"
      +$scope.list[9]+"\n"
      +$scope.list[10]+"\n";

is there any other way to insert a line break?


Solution

  • Try

    '\r\n'
    

    instead of

    '\n'
    

    For the explanation, see here.