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
?
After angular 1.2 you need to depend your module on ngRoute
var sampleApp = angular.module('sampleApp', ['ngRoute']);
If you click on the error in your Dev Console, you'll see this at the middle of the page:
In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x or later, be sure that you've installed ngRoute.
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']);