Skip to content

Commit

Permalink
Coffee: use controllerAs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehdy Dara committed Apr 7, 2015
1 parent b9c45a2 commit e845a42
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/templates/src/app/_ngroute/__ngroute.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
.when "/",
templateUrl: "app/main/main.html"
controller: "MainController"
controllerAs: "main"
.otherwise
redirectTo: "/"
5 changes: 3 additions & 2 deletions app/templates/src/app/_uirouter/__uirouter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
.config ($stateProvider, $urlRouterProvider) ->
$stateProvider
.state "home",
url: "/",
templateUrl: "app/main/main.html",
url: "/"
templateUrl: "app/main/main.html"
controller: "MainController"
controllerAs: "main"

$urlRouterProvider.otherwise '/'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
angular.module "<%= appName %>"
.controller "NavbarController", ($scope) ->
$scope.date = new Date()
.controller "NavbarController", () ->
vm = this
vm.date = new Date()
8 changes: 5 additions & 3 deletions app/templates/src/app/main/_main.controller.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
angular.module "<%= appName %>"
.controller "MainController", ($scope) ->
$scope.awesomeThings = <%= technologies %>
angular.forEach $scope.awesomeThings, (awesomeThing) ->
.controller "MainController", () ->
vm = this
vm.awesomeThings = <%= technologies %>
angular.forEach vm.awesomeThings, (awesomeThing) ->
awesomeThing.rank = Math.random()
return
2 changes: 1 addition & 1 deletion app/templates/src/app/main/_main.controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('controllers', function(){
}));

it('should define more than 5 awesome things', inject(function($controller) {
<% if (props.jsPreprocessor.key === 'none' || props.jsPreprocessor.srcExtension === 'es6') { %>
<% if (props.jsPreprocessor.key === 'none' || props.jsPreprocessor.srcExtension === 'es6' || props.jsPreprocessor.srcExtension === 'coffee') { %>
var vm = $controller('MainController', {
$scope: scope
});
Expand Down

0 comments on commit e845a42

Please sign in to comment.