javascriptangularjsurl-routingng-view

How to use routing and ng-view in AngularJS v1.3.3


I'm trying to run this example about routing, which uses AngularJS v1.0.7. But I want to make it work using AngularJS v1.3.3

Everything in my example works but the ng-view part. So I'm not sure whether the problem is the ng-view or the routing itself.

As the tutorial suggests, I tried 3 ways of calling ng-view. But none seems to work.

You can define ng-view in main html file in one of the below way.

<div ng-view=""></div>
<ng-view></ng-view>
<div class="ng-view"></div>

How should I make it work in AngularJS v1.3.3?


Solution

  • Older versions of angular included routing in the core.

    To use it now you have to include angular-route.js or angular-route.min.js also and inject ngRoute as a module dependency.

    var sampleApp = angular.module('sampleApp', ['ngRoute']);
    

    Original example upgraded