Вот мой 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
};
});
Что я здесь отсутствует?
'address == addresses2' theyre not reference equal – Caramiriel