Skip to content

Commit cdf1630

Browse files
author
mendhak
committed
Tidied the demo page
1 parent 0d66bd9 commit cdf1630

File tree

7 files changed

+159
-123
lines changed

7 files changed

+159
-123
lines changed

.idea/workspace.xml

+87-103
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/img/loading.gif

3.01 KB
Loading

sample/index.html

+31-8
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,48 @@
44
<meta charset="utf-8">
55
<title>My AngularJS App</title>
66

7+
<style type="text/css">
8+
body { font-family: Arial; font-size: 18px;}
9+
10+
div.box { border: 1px solid black; margin:5px; border-radius:11px; padding: 3px; float:left;}
11+
</style>
12+
713
</head>
814
<body>
915

10-
<h3>Open developer tools (F12) and wait for the beacon request in your network tab</h3>
16+
<span style="font-size:11px;">&larr; <a href="http://code.mendhak.com/angular-performance/">return</a></span>
17+
<h3>Open developer tools (F12) and wait for the beacon.png request in your network tab</h3>
18+
<h4>These DIVs are faking API calls and will complete in 1-10 seconds</h4>
19+
1120

1221
<div data-performance="PageName" data-performance-beacon="img/beacon.png">
1322

1423

24+
<div style="float:left;">
1525

16-
<div data-ng-controller="Controller1" data-performance-loaded="Loaded">
17-
<p>DIV 1 contents:</p>
18-
{{ Loaded }}
19-
</div>
26+
<div class="box" data-ng-controller="Controller1" data-performance-loaded="Loaded">
27+
<p>DIV 1 contents:</p>
28+
<div ng-show="Loaded">{{ Loaded }}</div>
29+
<div ng-hide="Loaded"><img src="img/loading.gif" /></div>
30+
</div>
31+
32+
<div class="box" data-ng-controller="Controller2" data-performance-loaded="Products">
33+
<p>DIV 2 contents:</p>
34+
<div ng-hide="Products"><img src="img/loading.gif" /></div>
35+
<div ng-show="Products" data-ng-repeat="n in Products.Names">{{ n }}</div>
36+
</div>
2037

21-
<div data-ng-controller="Controller2" data-performance-loaded="Products">
22-
<p>DIV 2 contents:</p>
23-
<div data-ng-repeat="n in Products.Names">{{ n }}</div>
38+
<div class="box" data-ng-controller="Controller3" data-performance-loaded="Status.Complete">
39+
<p>DIV 3 contents:</p>
40+
<div ng-hide="Status.Complete"><img src="img/loading.gif" /></div>
41+
<div ng-show="Status.Complete" >Three API calls complete</div>
42+
</div>
2443
</div>
2544

45+
46+
47+
48+
2649
</div>
2750

2851

sample/js/controllers.js

+41-6
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,56 @@ var controllers = angular.module('myApp.controllers', [])
66

77
controllers.controller('Controller1', ['$scope', '$timeout', function($scope, $timeout) {
88

9-
console.log("A long running process");
10-
119
$timeout(function() {
1210
$scope.Loaded = true;
13-
}, 3000);
11+
console.log("Controller 1 Done");
12+
}, (Math.random()*10)*1000);
1413
}]);
1514

1615

1716
controllers.controller('Controller2', ['$scope', '$timeout', function($scope, $timeout){
1817

19-
console.log("Another long running process");
18+
2019

2120
$timeout(function() {
2221
$scope.Products = { Names: ['Banana','Phone'], SaleType: 'TodayOnly' };
23-
}, 3330);
22+
console.log("Controller 2 Done");
23+
}, (Math.random()*10)*1000);
24+
25+
26+
}]);
27+
28+
29+
30+
31+
controllers.controller('Controller3', ['$scope', '$timeout', function($scope, $timeout){
32+
33+
var loaded = function() {
34+
if($scope.Object1 && $scope.Object2 && $scope.Object3){
35+
console.log("Controller 3 Done");
36+
$scope.Status = { Complete: true }
37+
}
38+
}
39+
40+
41+
$timeout(function() {
42+
$scope.Object1 = {x:193};
43+
44+
loaded();
45+
}, (Math.random()*10)*1000);
46+
47+
48+
$timeout(function() {
49+
$scope.Object2 = {y:293};
50+
51+
loaded();
52+
}, (Math.random()*10)*1000);
53+
54+
55+
$timeout(function() {
56+
$scope.Object3 = {z:444};
2457

58+
loaded();
59+
}, (Math.random()*10)*1000);
2560

26-
}]);
61+
}]);

sample/partials/.gitkeep

Whitespace-only changes.

sample/partials/partial1.html

-1
This file was deleted.

sample/partials/partial2.html

-5
This file was deleted.

0 commit comments

Comments
 (0)