This might be late to the game with Angular 2 being the new kid on the block, but I recently came across this in a corner of a project. I've not worked on many Angular apps of this scale (with regards to team members contributing), and I'd like to see why this code is implemented as follows:
app.js:
angular
.module('myModule')
.controller('AppCtrl', ['$scope','$rootScope', function($scope, $rootScope) {
$scope.SideMenuCtrl = function ($scope) {
$scope.staticMenu = _service.getMenuList($rootScope.acctId);
};
}]);
index.html:
<!DOCTYPE html>
<html ng-app="ngApp" ng-controller="AppCtrl">
<head></head>
<body>
<header></header>
<div id='wrapper' ng-hide="hideNav()">
<div id='main-nav-bg'></div>
<nav id='main-nav' class='main-nav-fixed'>
<div class='navigation'>
<ul class='nav nav-stacked' ng-controller="SideMenuCtrl">
</ul>
<div>
<nav>
</div>
Question:
I'm trying to understand why / what the reasoning / benefit would be to assign nested controllers like this, and not having dedicated angular controllers? Isn't this breaking (assumed) convention / mixing different purposes?