ng-view and index.html

167 views
Skip to first unread message

ma

unread,
Dec 14, 2012, 6:13:37 AM12/14/12
to ang...@googlegroups.com
Hey guys,

I am having trouble with my ng-view in my index file and I could really need som explenation to some questions regarding ng-view and including controllers.

I have an index.html file with a fixed sidebar.

1. As far as I have understood I need to include <ng-view></ng-view> in my index.html file? And I have done so right after the mark-up for the fixed sidebar. Is this correct?

<html ng-app="myApp>
...
<body>

mark up for sidebar...

<ng-view></ng-view>

2. I have a 'Session' controller that handles login and logout andI have a login / logout button in my sidebar but if I use ng-controller in a div element in my sidebar I just get LoginController is undefined.

- Do I have to some manual routing if I try to include this controller here?

I guess this problem comes from me not fully understanding ng-view and how to include controllers in a index file in the markup using ng-controller so nice explenations regarding this would be very highly appreciated!

Thanks! :)









tas pas

unread,
Dec 14, 2012, 6:16:46 AM12/14/12
to ang...@googlegroups.com
I think that this will help you understand a little better what's going on with routes.
john Lindquist wrote a good tutorial on them.
I hope he makes more...

ma

unread,
Dec 14, 2012, 7:12:11 AM12/14/12
to ang...@googlegroups.com
Thanks! I guess it makes more sense.

it's just that I get so confused from using angular-seed and them watching these videoes where they set up everything manually.

ma

unread,
Dec 14, 2012, 7:21:07 AM12/14/12
to ang...@googlegroups.com
E.g. In the video he does the following to enable html5 mode to remove the '#' in the URL:

angular.module('app', []).

config(function ($routeProvider, $locationProvider){
    $locationProvider.html5(true);

    $routeProvider.
        when(//sets path to partial
}


When I try to do the same thing in the app.js by adding this code:

angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']).
  config(['$routeProvider', '$locationProvider',
   function($routeProvider, $locationProvider) {

    $locationProvider.html5mode(true);

    $routeProvider.when('// set paths to partial


all I get is error: Object #<$LocationProvider> has no method 'html5mode' from myApp

It's just that the angular-seed set up makes it a bit confusing when looking at examples.
Reply all
Reply to author
Forward
0 new messages