I'm trying to set up a small application to learn how to set up an angular 1 project (yes, 1. We are on 1 at the office and I want to learn it).
Part of it works, but when I add another controller, it falls apart. My project looks like this:
app.js:
angular.module('app', [
'app.controllers',
'ds.clock'
]);
clockController.js:
angular.module('app.controllers', []).controller('clockController',
function($scope) {
"use strict";
$scope.Name = "Angular";
});
index.html (abbreviated):
<body ng-app="app">
<div ng-controller="clockController" style="float:right;width:20%x;margin:auto">
{{Name}}
<div>
<div><ds-widget-clock show-analog></ds-widget-clock></div>
</div>
My clocks are shown as well as the 'Name' property on the scope.
But, now I try to add an extra controller:
tickerController.js
angular.module('app.controllers').controller('tickerController',
function($scope) {
'use strict';
$scope.Name = 'ticker'; });
I also add a link to it in the <head>
:
<script src="js/app.js"></script>
<script src="js/clockController.js"></script>
<script src="js/tickerController.js"></script>
And of course an extra div in the index.html
<div ng-controller="tickerController" >
{{ $scope.Name }}
</div>
<div ng-controller="clockController"........
But now I get slapped around with the following error:
angular.js:14700 Error: [$controller:ctrlreg] The controller with the name 'clockController' is not registered.
And my page stays mostly blank.
How to proceed now?