Don’t put ng-app and ng-view on the same element.

I was having a problem where Angular’s routing system wasn’t working in my application. After some experimentation I found this out:

If you have an element like

<div ng-app="app" ng-view>Stuff</div>

then links which go to known routes won’t get handled by Angular’s, rather, they just act like a normal link would. The solution was simple: put each attribute on a different element.

<div ng-app="app">
    <div ng-view>
        Content
    </div>
</div>

Angular version: 1.2.0rc2

This entry was posted in Development and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *