I'm trying to figure out how to use a slug (attribute of my model) in my ember routes to get cleaner urls.
I'd like that my routes look like this:
http://www.server.com/#/newsitems/newsitem-title-in-slug-format/1
Instead of:
http://www.server.com/#/newsitems/1/1
As you can see, I'd like to replace the id of the newsitem with the actual slug attribute. Here's how my Newsitem
model looks like:
App.Newsitem = DS.Model.extend({
slug: DS.attr('string'),
title: DS.attr('string'),
summary: DS.attr('string'),
});
The slug property receives a clean text attribute in this format: title-in-slug-format
This is my router map at the moment:
App.Router.map(function(){
this.resource('newsitems', function(){
this.resource('newsitem', {path:':newsitem_id'});
});
});
I tried replacing the newsitem_id
with newsitem_slug
but this isn't working. Any other suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…