0
這裏是我的SimpleSchema:這兩個數組之間有什麼區別,爲什麼typeahead w/autoform只能和其中的一個一起工作?
confirmedAddress: {
//addressRecordID
type: String,
label: "Address",
optional: true,
autoform: {
type: "typeahead",
/*
options: function() {
return [{
label: "2013",
value: 2013
}, {
label: "2014",
value: 2014
}, {
label: "2015",
value: 2015
}]
}
*/
options: function() {
var addresses = Addresses.find({
houseNumber: "0"
}).map(function(address) {
return {
label: address.houseNumber + " " + address.street + ", " + address.unit + ", " + address.city,
value: address._id
};
});
/*console.log("addresses",addresses)*/
var addresses2 = [{
"label": "0 Unknown, undefined, undefined",
"value": "rec2I5yyHm6rSQOAO"
}, {
"label": "0 unknown, undefined, undefined",
"value": "recBEYzyvjfCm0D4k"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "recFdDsCzYgXGWWyC"
}, {
"label": "0 SE Muskogee Ave, undefined, undefined",
"value": "recH0g6UvLrztSCCR"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "recK8aT6gQoRsqDVP"
}, {
"label": "0 unknown, undefined, undefined",
"value": "recKstPZAt5wrGzRT"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "recSf7X7LLIWqvvGK"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "recbUExSc2Rd1kFSp"
}, {
"label": "0 Oak, undefined, undefined",
"value": "recekb3FlD6vghcf0"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "rechiCWJ9ScAeBOC4"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "reclUGe2NkeLSafWj"
}, {
"label": "0 unknown, undefined, undefined",
"value": "reclsD03UdhBwLc6b"
}, {
"label": "0 Moved out of territory, undefined, undefined",
"value": "recrLqh76Qk7EHQcm"
}, {
"label": "0 Unknown, undefined, undefined",
"value": "recyyDLXMkHMRf9bn"
}]
console.log(addresses, addresses2)
console.log("addresses == addresses2", addresses == addresses2) // false
return addresses2
}
}
}
第一註釋部分工作正常。返回addresses2
也可以正常工作。但是,當我返回addresses
時,typeahead不起作用。
的事情是,我通過這個粘貼到控制檯,然後複製成代碼得到addresses2
:
Addresses.find({
houseNumber: "0"
}).map(function(address) {
return {
label: address.houseNumber + " " + address.street + ", " + address.unit + ", " + address.city,
value: address._id
};
});
缺少什麼我在這裏?
'addresses == addresses2' theyre not reference equal – Caramiriel