Skip to content

Commit 376ad25

Browse files
committed
angular-js example cleanup
1 parent b1f7153 commit 376ad25

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

angular-js-example.html renamed to examples/angular-js-example.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<title>Timer Directive used from AngularJS</title>
5-
<script src="angular/angular.min.js"></script>
6-
<script src="app/js/timer.js"></script>
5+
<script src="../angular/angular.min.js"></script>
6+
<script src="../app/js/timer.js"></script>
77
<script>
88
angular.module('MyApp', ['timer']);
99
function MyAppController($scope) {
@@ -38,4 +38,4 @@ <h3>Timer 2: <timer>{{minutes}} minutes, {{seconds}} seconds.</timer></h3>
3838
<button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timers</button>
3939
</div>
4040
</body>
41-
</html>
41+
</html>

index.html

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ <h3><timer id="timer3">{{minutes}} minutes, {{seconds}} seconds.</timer></h3>
110110
<button type="button" class="btn" onclick="stopTimer('timer3', this)">Stop</button>
111111
</div>
112112
</section>
113-
<h2>Examples</h2>
113+
<h3>Examples</h3>
114114
<section id="angularjs-example">
115-
<h3>Using timer directive from Angular</h3>
115+
<h4>Using timer directive from Angular</h4>
116116
<ul class="nav nav-tabs" id="myTab">
117117
<li class="active"><a data-toggle="tab" href="#angularjs-example-source">index.html</a></li>
118118
<li><a data-toggle="tab" href="#angularjs-example-demo">Demo</a></li>
@@ -121,13 +121,50 @@ <h3>Using timer directive from Angular</h3>
121121
<div class="tab-content">
122122
<div class="tab-pane active" id="angularjs-example-source">
123123
<pre class="prettyprint linenums">
124-
<code>
125-
&lt;a data-toggle="modal" href="remote.html" data-target="#modal"&gt;click me&lt;/a&gt;
126-
</code>
127-
</pre>
124+
&lt;!DOCTYPE html&gt;
125+
&lt;html&gt;
126+
&lt;head&gt;
127+
&lt;title&gt;Timer Directive used from AngularJS&lt;/title&gt;
128+
&lt;script src="angular/angular.min.js"&gt;&lt;/script&gt;
129+
&lt;script src="app/js/timer.js"&gt;&lt;/script&gt;
130+
&lt;script&gt;
131+
angular.module('MyApp', ['timer']);
132+
function MyAppController($scope) {
133+
$scope.timerRunning = true;
134+
135+
$scope.startTimer = function (){
136+
$scope.$broadcast('timer-start');
137+
$scope.timerRunning = true;
138+
};
139+
140+
$scope.stopTimer = function (){
141+
$scope.$broadcast('timer-stop');
142+
$scope.timerRunning = false;
143+
};
144+
}
145+
MyAppController.$inject = ['$scope'];
146+
&lt;/script&gt;
147+
&lt;/head&gt;
148+
&lt;body ng-app="MyApp"&gt;
149+
&lt;div ng-controller="MyAppController" style="border: 1px solid gainsboro; text-align: center;"&gt;
150+
&lt;h2&gt;Single Timer&lt;/h2&gt;
151+
&lt;h3&gt;&lt;timer/&gt;&lt;/h3&gt;
152+
&lt;button ng-click="startTimer()" ng-disabled="timerRunning"&gt;Start Timer&lt;/button&gt;
153+
&lt;button ng-click="stopTimer()" ng-disabled="!timerRunning"&gt;Stop Timer&lt;/button&gt;
154+
&lt;/div&gt;
155+
&lt;br/&gt;
156+
&lt;div ng-controller="MyAppController" style="border: 1px solid gainsboro; text-align: center;"&gt;
157+
&lt;h2&gt;Multiple Timers&lt;/h2&gt;
158+
&lt;h3&gt;Timer 1: &lt;timer interval="2000"/&gt;&lt;/h3&gt;
159+
&lt;h3&gt;Timer 2: &lt;timer&gt;{{minutes}} minutes, {{seconds}} seconds.&lt;/timer&gt;&lt;/h3&gt;
160+
&lt;button ng-click="startTimer()" ng-disabled="timerRunning"&gt;Start Timers&lt;/button&gt;
161+
&lt;button ng-click="stopTimer()" ng-disabled="!timerRunning"&gt;Stop Timers&lt;/button&gt;
162+
&lt;/div&gt;
163+
&lt;/body&gt;
164+
&lt;/html&gt;</pre>
128165
</div>
129166
<div class="tab-pane" id="angularjs-example-demo">
130-
<h1>Demo</h1>
167+
<iframe src="examples/angular-js-example.html" width="100%" height="350px"></iframe>
131168
</div>
132169
</div>
133170
</section>

0 commit comments

Comments
 (0)