
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
angular-object-diff
Advanced tools
An Angular JS plugin to compare and show object differences in JSON format. Demo
with bower
bower install angular-object-diff --save
<link type="text/css" href="bower_components/dist/angular-object-diff.css" rel='stylesheet'>
<script type="text/javascript" src="bower_components/dist/angular-object-diff.js"></script>
or with npm
npm i angular-object-diff
ObjectDiff
servicesetOpenChar
: set the opening character for the view, default is {
setCloseChar
: set the closing character for the view, default is }
diff
: compare and build all the difference of two objects including prototype properties
diffOwnProperties
: compare and build the difference of two objects taking only its own properties into account
toJsonView
: format a diff object to a full JSON formatted object view
toJsonDiffView
: format a diff object to a JSON formatted view with only changes
objToJsonView
: format any javascript object to a JSON formatted view
toJsonView
: format a diff object to a full JSON formatted object view
toJsonDiffView
: format a diff object to a JSON formatted view with only changes
objToJsonView
: format any javascript object to a JSON formatted view
Declare the dependency
angular.module('myModule', ['ds.objectDiff']);
Inject the service
angular.module('myModule')
.controller('MyController', ['$scope', 'ObjectDiff', function($scope, ObjectDiff){
$scope.yourObjectOne = {//all your object attributes and values here};
$scope.yourObjectTwo = {//all your object attributes and values here};
// This is required only if you want to show a JSON formatted view of your object without using a filter
$scope.yourObjectOneJsonView = ObjectDiff.objToJsonView($scope.yourObjectOne);
$scope.yourObjectTwoJsonView = ObjectDiff.objToJsonView($scope.yourObjectTwo);
// you can directly diff your objects js now or parse a Json to object and diff
var diff = ObjectDiff.diffOwnProperties($scope.yourObjectOne, $scope.yourObjectTwo);
// you can directly diff your objects including prototype properties and inherited properties using `diff` method
var diffAll = ObjectDiff.diff($scope.yourObjectOne, $scope.yourObjectTwo);
// gives a full object view with Diff highlighted
$scope.diffValue = ObjectDiff.toJsonView(diff);
// gives object view with onlys Diff highlighted
$scope.diffValueChanges = ObjectDiff.toJsonDiffView(diff);
}]);
Bind the variables directly in your html using the ng-bind-html
angular directive.
Use a <pre>
element for better results
<pre ng-bind-html="diffValue"></pre>
<pre ng-bind-html="diffValueChanges"></pre>
<pre ng-bind-html="yourObjectOneJsonView"></pre>
<pre ng-bind-html="yourObjectTwoJsonView"></pre>
The same can be done with filters as well
angular.module('myModule')
.controller('MyController', ['$scope', 'ObjectDiff', function($scope, ObjectDiff){
$scope.yourObjectOne = {//all your object attributes and values here};
$scope.yourObjectTwo = {//all your object attributes and values here};
// you can directly diff your objects js now or parse a Json to object and diff
var diff = ObjectDiff.diffOwnProperties($scope.yourObjectOne, $scope.yourObjectTwo);
// you can directly diff your objects including prototype properties and inherited properties using `diff` method
var diffAll = ObjectDiff.diff($scope.yourObjectOne, $scope.yourObjectTwo);
}]);
Bind the variables directly in your html using the ng-bind-html
angular directive.
Use a <pre>
element for better results
<pre ng-bind-html="diffValue | toJsonView"></pre>
<pre ng-bind-html="diffValueChanges | toJsonDiffView"></pre>
<pre ng-bind-html="yourObjectOneJsonView | objToJsonView"></pre>
<pre ng-bind-html="yourObjectTwoJsonView | objToJsonView"></pre>
Inspired from https://github.com/NV/objectDiff.js
FAQs
An Angular JS plugin to compare and show object differences.
The npm package angular-object-diff receives a total of 401 weekly downloads. As such, angular-object-diff popularity was classified as not popular.
We found that angular-object-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.