我对快递/猫鼬还很陌生,无法弄清楚为什么我的路线不起作用。我正在使用 MEAN 堆栈。
我有一条一般报价路线“/offers”,然后是特定报价路线“/offers/television”和“/offers/laptops”,但是当尝试路由到特定路线时,它通过“/offers”而不是我拥有的路线书面。
我错过了什么?
谢谢!
我的代码:
索引.html
<a href="#!/offers/televisions">Television Offers</a>
配置.js
when('/offers',{
templateUrl: 'views/offers/list.html'
}).
when('/offers/televisions',{
templateUrl: 'views/offers/list.html'
}).
when('/offers/laptops',{
templateUrl: 'views/offers/list.html'
})
路由.js
//Offer Routes
var offers = require('../app/controllers/offers');
app.get('/offers', offers.all);
app.get('/offers/televisions', offers.televisions);
app.get('/offers/laptops', offers.laptops);
提供.js
/**
* Find all offers
*/
exports.all = function(req, res){
console.log('all');
Offer.find({}, function(err, offers){
if (err) {
res.render('error', {
status: 500
});
} else {
res.jsonp(offers);
}
});
};
/**
* Find all television offers
*/
exports.televisions = function(req, res){
console.log('televisions');
Offer.find({type: 'television'}, function(err, offers){
if (err){
res.render('error', {
status:500
});
}else{
console.log(offers);
res.jsonp(offers);
}
});
};