I want to create a controller inside one of my views .. I have a structure like this
index.html
pages > home.html
js > app.js, controllers.js
app.js:
angular.module('app').config(function ($routeProvider) {
$routeProvider.when('/home', {templateUrl: '/pages/home.html', controller: 'HomeCtrl'});
});
controllers.js :
angular.module('app.controllers', []).controller('HomeCtrl', function(){ ... });
Everything is working great but is it possible to create another controller inside home.html file ?
I tried this but not working
home.html :
<div ng-controller="InsiderCtrl">
</div>
<script type="text/javascript">
angular.module('app.controllers').controller('InsiderCtrl', function(){ ... });
</script>
But when I tried using function instead it worked! Can anyone explain me why? Isn't it possible to access the modules inside a view ?
<div ng-controller="InsiderCtrl">
</div>
<script type="text/javascript">
function InsiderCtrl() {}
</script>
composer update