Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbraus committed May 19, 2015
1 parent f163295 commit 3ce0d5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
angular.module('starter', [])

.controller("NavbarCtrl", ['$scope', '$rootScope', function ($scope, $rootScope) {

.controller("MyFirstCtrl", ['$scope', function ($scope) {
$scope.current_user = { points_count: 3 };

$rootScope.$on('addPoint', function() {
$scope.current_user.points_count = ++$scope.current_user.points_count
})
}])

.controller("MyFirstCtrl", ['$scope', '$rootScope', function ($scope, $rootScope) {

$scope.foo = { bar: 'My First Angular App' }


$scope.addPoint = function() {
$rootScope.$broadcast('addPoint')
}
}]);
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
<input ng-model="foo.bar" class='form-control' autofocus/>
<br>
<i class="icon ion-home"></i> {{foo.bar}}
<button ng-click="addPoint()">Add Point</button>
</div>


<script type="text/ng-template" id="navbar.html">
<nav class="navbar navbar-default">
<nav class="navbar navbar-inverse" style="border-radius:0;" ng-controller="NavbarCtrl">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
Expand All @@ -47,7 +48,7 @@
<li><a href="#">Link</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li><a href="#">{{current_user.points_count}} Points</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
Expand Down

0 comments on commit 3ce0d5c

Please sign in to comment.