1

I am working on AngularJS application i want to compare text and highlight the difference in another div. Below is my code

$scope.left="one two three";
$scope.right="one two four";

<div>{{diff}}</div>

in above context if we compare two scope's left and right we get to know that "three" is extra in $scope.left and "four" is extra in $scope.right . So we need to highlight "three" in red color and "four" in green color so that it will be easy to find the difference.

Is there any plugins or library i can use for this functionality ?

Boswell Gathu
  • 451
  • 3
  • 7
Bhushan Khaladkar
  • 420
  • 1
  • 7
  • 20
  • https://stackoverflow.com/questions/29573700/finding-the-difference-between-two-string-in-javascript-with-regex – btlm Jul 07 '17 at 06:56

1 Answers1

4

I know a good library jsdiff: https://github.com/kpdecker/jsdiff

A simple example: http://incaseofstairs.com/jsdiff/

Is it what you are looking for?

Satabol
  • 76
  • 1
  • 5