Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Last active January 1, 2016 03:49
Show Gist options
  • Save telagraphic/8087999 to your computer and use it in GitHub Desktop.
Save telagraphic/8087999 to your computer and use it in GitHub Desktop.
angular controller argument is not a function, got undefined
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
'use strict';
/* Controllers */
angular.module('myApp.controllers', []).controller('BettingController', ['$scope', function($scope) {
$scope.name = "Nick Name";
}]);
angular.module('myApp.controllers', []).controller('ResultsController', [function() {
}]);
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Flow Better</title>
<link rel="stylesheet" href="css/app.css"/>
</head>
<body>
<!-- >
<ul class="menu">
<li><a href="#/">Make A Bet</a></li>
<li><a href="#/view2">Results</a></li>
</ul>
<div ng-view></div>
<-->
<section ng-controller="BettingController">
<h1>Place Your Flow Time Bet</h1>
<h2>{{name}}</h2>
<form>
<label>Name:</label>
<input></input>
<br>
<label>Time Bet:</label>
<input></input>
</form>
</section>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
-->
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment