But also, manually with angular.bootstrap(...)
{}, a POJO.
function MainCtrl($scope) { $scope.name = "Crocodile Dundee"; }ng-controller="MainCtrl"
<ul ng-repeat="item in items"> <li>{{ item }}</li> </ul>
myApp.controller('MainCtrl', function ($scope, $log) { ... }) myApp.service('users', function ($http, $location) { ... }) myApp.directive('tabs', function ($filter) { ... })
Many ways to create:
return an instance -> myApp.service('tabs', function () ...) return an object -> myApp.factory('tabs', function () ...) configure when module is load -> myApp.provider('tabsProvider', function () ...)
var modal = angular.module('modal', []); modal.controller('MainCtrl', function () { ... }); var monolithicSPA = angular.module('SPA2012', ['redisclient', 'modal', 'phase4buttons']);
...is a pain, due to DI.
// inferred (only works in unminified code) $injector.invoke(function(serviceA){}); // annotated function explicit(databaseService) {}; explicit.$inject = ['databaseService']; $injector.invoke(explicit); // inline (used in ngSchedule) $injector.invoke(['databaseService', function(databaseService){}]);