I am just starting with emberjs. I am creating a simple index.html page with two links on top: About and Posts. This is following the standard example on emberjs homepage. I get an error in the browser
"Uncaught TypeError: Cannot call method 'map' of undefined"
So this means that my router is undefined. Why is that?
Here is the app.js code:
var App = Ember.Application.create();
App.router.map(function(){
});
So I tried to define it ...
var App = Ember.Application.create();
App.Router = Ember.Router.extend({
enableLogging: true,
location: 'hash'
});
App.Router.map(function(){
});
I still get the error. I am confused :(.
Make sure you are using the latest version of Ember (1.0.0-RC.2) from http://emberjs.com/.
The example you posted is the old style router which is not used anymore. The new style is explained in this guide and is defined like this:
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});