Angular JS - Exposing Controller Function outside the module via onClick function call
Exposing Controller Function outside the module via onClick function call
For re-using already defined onClick functions
HTML
<div ng-app="ManagerApp">
<div ng-controller="MainCtrl">
Main:
<div ng-repeat="state in states">
{{state}}
</div>
<div ng-controller="InsideCtrl as inside">
Inside:
<div ng-repeat="state in inside.states2">
{{state}}
</div>
</div>
</div>
</div>
<!-- /app -->
JavaScript
/*app.js tabs*/
var angularApp = angular.module('ManagerApp', []);
angularApp.controller('MainCtrl', ['$scope', function ($scope) {
$scope.states = ["NY", "CA", "WA"];
}]);
angularApp.controller('InsideCtrl', ['$scope', function ($scope) {
var vm = this;
vm.states2 = ["NY", "CA", "WA", "LS"];
}]);