Skip to content

Commit 1cb30ef

Browse files
author
Warren Seymour
committed
Add namespace example
1 parent 7c1e99a commit 1cb30ef

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examples/6-namespaces.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>AngularJS Workshop &middot; Namespaces</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link href="/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
7+
</head>
8+
<body ng-app="MyApp">
9+
<div class="container">
10+
<h1 class="page-header">AngularJS Workshop &middot; Namespaces</h1>
11+
12+
<div ng-controller="PersonController">
13+
<p>{{ person.name }} is {{ person.age }} years old</p>
14+
15+
<button class="btn" ng-click="birthday()">Get older</button>
16+
</div>
17+
</div>
18+
19+
<script src="/lib/angular/angular.js"></script>
20+
<script src="js/namespaces.js"></script>
21+
</body>
22+
</html>

examples/js/namespaces.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
angular.module('MyApp', [])
2+
.controller('PersonController', function($scope) {
3+
$scope.person = {
4+
name: "Warren Seymour",
5+
age: 28
6+
};
7+
8+
$scope.birthday = function() {
9+
$scope.person.age += 1;
10+
};
11+
});

0 commit comments

Comments
 (0)