Using controller inside another controller in AngularJS
As you are using controllerAs
you should be using this
keyword in controller
angularApp.controller('InsideCtrl', [ function() { var vm = this; vm.states2 = ["NY", "CA", "WA"];}]);
NOTE
Technically you should follow one approach at a time. Don't mix up this two pattern together, Either use
controllerAs
syntax/ Normal controller declaration as you did forMainCtrl
using$scope
Remove
as inside
from here:
<div ng-controller="InsideCtrl as inside">
such that:
`<div ng-controller="InsideCtrl">`
<div ng-app="ManagerApp"> <div ng-controller="MainCtrl"> Main: <div ng-repeat="state in states"> {{state}} </div> <div ng-controller="InsideCtrl"> Inside: <div ng-repeat="state in states2"> {{state}} </div> </div> </div></div>