Hi everybody I am new to angular and still trying to get the basics down. I have a view that has two controllers controlling two different pieces of that view:
<div class="row" ng-app="appDiary">
<div ng-controller="entryController as vm">
....
</div>
<div ng-controller="otherController as vm">
....
</div>
<div>
entryController.js / otherController.js:
angular.module("appDiary").controller("entryController", entryController);
function entryController($scope, $http, $filter, service) {
...functionality here...
}
Basically the view html has gotten long and I want to break it up into templates. I tried searching around and using the ngRoute
.
angular.module('appDiary', ['simpleControls', 'chart.js', 'ngRoute']);
.config(function ($routeProvider) {
$routeProvider.when("/", {
controller: "entryController", "otherController" // Want both controllers here
controllerAs: vm,
templateUrl: "/views/entry.html", "/views/other.html"
});
});
How do I get Angular to map two controllers/templates to one route? Is there a better way to do this? I tried using some suggestions from Routing in angularjs for mutliple controllers? and couldn't get anything working. Thank you!