我希望有一个像这样/restaurants/:pageNumber
的网址,我希望/restaurants
假设pageNumber参数为1。
这是我的Router.js
:
Router.map(function() {
this.route('restaurants', function() {});
this.route('restaurants', { path: '/restaurants/:pageNumber' }, function() {});
});
如果删除了function() {}
,我只会在/restaurants/1
我的routes/restaurants/index.js
:
export default Ember.Route.extend({
ajax: Ember.inject.service(),
model(params) {
return Ember.RSVP.hash({
response: this.get('ajax').request('/getAllRestaurants', {method: 'GET'}),
currentPage: params.pageNumber | 1
});
}
});
在templates/restaurants/index.hbs
我检查{{model.currentPage}}
,它始终是1
。
答案 0 :(得分:0)
您是否尝试过int m; //This will be received thru the serial Port.
String Mnemonic="";
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 5;
int ledPin4 = 6;
void setup()
{
Serial.begin(9600); //Set Baud Rate of Serial
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
pinMode(ledPin4,OUTPUT);
}
void loop()
{
if(Serial.available()>0) //Check if serial port is open.
//get the number of bytes available for reading
{
m=Serial.read(); //Read Incoming char from the PC.
Mnemonic += (char)m;
if (Mnemonic=="LDA")
{
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,HIGH);
}
else if (Mnemonic=="ADD")
{
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,LOW);
}
else if (Mnemonic=="SUB")
{
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
}
else if (Mnemonic=="HLT")
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,LOW);
}
else if (Mnemonic=="OUT")
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
}
if(m==10) Mnemonic = "";
Serial.flush();//removed any buffered incoming serial data
}
}
和
{ path: '/restaurants/:page_number' }
?
答案 1 :(得分:0)
因为逻辑OR是||,而不是|。 page = params.pageNumber || 1
。但更可靠的是三元运算符page = (params.pageNumber !== undefined ? params.pageNumber : 1)