Created
November 18, 2014 14:19
-
-
Save kalbarczyk/58231115e8becd0b690c to your computer and use it in GitHub Desktop.
AngularJS - funkcja equals - przykład z naszej książki „AngularJS - Pierwsze kroki”, która ukaże się na początku 2015r. dzięki wydawnictwu Helion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html data-ng-app="app"> | |
<head> | |
<title>AngularJS - funkcje - angular.equals</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" /> | |
</head> | |
<body> | |
<div data-ng-controller="defaultCtrl"> | |
<pre> | |
Obiekt 1: {{obj1}} | |
Obiekt 2: {{obj2}} | |
Obiekt 3: {{obj3}} | |
Obiekt 1 = Obiekt 2 -> {{test1}} | |
Obiekt 1 = Obiekt 3 -> {{test2}} | |
</pre> | |
</div> | |
<script src="https://code.angularjs.org/1.3.0/angular.js"></script> | |
<script> | |
var app = angular.module('app', []); | |
app.controller('defaultCtrl', function ($scope) { | |
$scope.obj1 = { key1: "wartosc1", key2: "wartosc2", key3: { a: "a1", b: "b1", c: "c1" } }; | |
$scope.obj2 = { key3: { a: "a1", b: "b1", c: "c1" }, key2: "wartosc2", key1: "wartosc1" }; | |
$scope.obj3 = { key3: { a: "a1", b: "b1", c: "c1" }, key2: "wartosc1", key1: "wartosc2" } | |
$scope.test1 = angular.equals($scope.obj1, $scope.obj2); // true | |
$scope.test2 = angular.equals($scope.obj1, $scope.obj3); //false | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment