Blank page using multiple views with UI-Router
Asked Answered
C

2

6

I followed this article and this other I've tried to replicate what's on the wiki, without any luck.

So far this is what I've done the folder structure:

  • partial
    • index
      • index.html // inner view
      • index.css
      • index.js //controller
    • footer
      • footer.html
      • footer.js
    • header
      • // same structure
  • index.html // main file

stateProvider:

angular.module('app').config(function($stateProvider, $urlRouterProvider) {
        $stateProvider.state("index",
        {
            url: "/index",
            templateUrl:'/partial/index.html',
            views: {
                'footer@index': {
                    templateUrl: "/partial/header.html",
                    controller:"FooterCtrl"
                },
                'header@index': {
                    templateUrl: "/partial/header.html",
                    controller: "HeaderCtrl"
                }
            }
    });  
 $urlRouterProvider.otherwise('/index');

EDIT:

this is the markup:

<div>
    <div id="content" class="container">

        <div ui-view="header"></div>
        <div ui-view></div>
        <div ui-view="footer"></div>

    </div>
  </div>

the url I'm browsing is: localhost:9001/#/index

I don't get any error just a blank page

Constantinople answered 29/5, 2014 at 1:58 Comment(0)
B
2

Looks like you used incorrect paths on the templateUrl.

Here's the plunker using ui-router: http://plnkr.co/edit/Nqwlkq1vGh5VTBid4sMv?p=preview

I also suggest reading the source code of http://angular-ui.github.io/ui-router/sample/#/ it has an abstract implementation here and many comments on how to work with ui-router properly.

Bow answered 29/5, 2014 at 2:12 Comment(4)
thanks for the suggestion I noticed that I was getting 404 errors that fixed them but I'm still getting a blank pageConstantinople
Ok i'm guessing you that you're missing the ui-view directives on your markup? can you add your markup there?Bow
I've updated the markup, let's say that I guess that the ui-view in blank will be loaded because of the 'route'Constantinople
Read more about the ui-router sample it helped me alot when dealing with the ui-views. :) npBow
E
0

don't left a slash at the end of the url

not working: http://sjhite.com/questions/23924587/

working: http://sijhte.com/questions/23924587

Eady answered 16/2, 2016 at 19:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.