I'm trying to create the 'main layout' for my page using ui-router views, but I can't seem to get it working right (various errors, controllers not getting called, templates not getting loaded).
<!DOCTYPE html>
<html ng-app="App">
<head>
...
</head>
<body>
<header ui-view="header">
</header>
<section ui-view="navigation">
</section>
<section ui-view="content">
</section
</body>
</html>
The idea is to have a state representing the "root" state for the whole site providing templates for navigation and header as well as a "root controller". Every other state loads it's content into the "content" view without affecting the others.
$stateProvider
.state("index", {
url: "/",
controller: "App.IndexController",
controllerAs: "vm",
views: {
"header@index" : { templateUrl: "app/main/header.html" }
// nav etc.
}
The app loads without any errors, but the templates as well as the controller never get invoked. Did I miss something?
I also saw that many people provide a separate "layout" view that get's loaded into an unnamed view (mostly on the <body>
tag), but I consider this useless as the main index.html
file is already my layout. Or: Is there a better way to achieve what I want?