【发布时间】:2016-07-13 01:19:01
【问题描述】:
所以我有一个带有流星辅助方法的 Angular 控制器,如下所示。
function localeCtrl($scope, $reactive, $stateParams{
$reactive(this).attach($scope);
var self = this;
self.helpers({
locale: function(){ return Locales.findOne($stateParams.id)},
staff: function(){
// Load data from second collection based on current Locale.
// But how?
},
address: function(){
// Take self.location.address and massage it to provide
// google maps link. How?
}
tags: function(){
// Collect all unique instances of a given tag by
// iterating over the available locales.
// E. G. If 10 locales have the 'restaurant' tag, and 5
// more have the 'library' tag, I want an array of
// ['restaurant', 'library'] -- easy enough to do
// by iterating over the locales, but how do I do that
// reactively?
}
});
}
不幸的是,我需要根据 locale() 获取的数据设置其他属性。当我初始化控制器时,我无法设置它们,因为 locale() 中的值会随着从服务器获取数据而改变。但我需要访问语言环境中的数据,例如,创建谷歌地图地址或获取相关记录。 (出于我当时确信的原因,它们没有嵌入语言环境文档中)。
编辑:
此外,我使用地面数据库来存储数据的本地副本以供离线访问,这让生活变得更加复杂。
【问题讨论】:
标签: meteor angular-meteor