Angularjs 角度firebase外键/ng重复
我在firebaseAngularjs 角度firebase外键/ng重复,angularjs,firebase,crud,Angularjs,Firebase,Crud,我在firebasedepartmentos->parent和Ciudades->child中有两个表。当我在ng repeat视图中显示城市时,我需要将$iddepartmento替换为departmentos表中的名称。我怎么做 数据库: 视图: {{obj.idItem} {{obj.nombreCiudad} {{obj.departmentoecuidad}}您需要使用departmentoecuidad对departmentos表进行另一次查找,然后将其添加到ng repea
departmentos
->parent和Ciudades
->child中有两个表。当我在ng repeat
视图中显示城市时,我需要将$id
departmento
替换为departmentos
表中的名称。我怎么做
数据库:
视图:
{{obj.idItem}
{{obj.nombreCiudad}
{{obj.departmentoecuidad}}您需要使用departmentoecuidad对departmentos表进行另一次查找,然后将其添加到ng repeat对象中
$scope.ciudades.departamentoObj = $firebaseObject(rootRef.child(departamentoEciudad));
<td>{{obj.departamentoObj.nombreDepartamento }}</td>
$scope.ciudades.departmentoobj=$firebaseObject(rootRef.child(departmentoecudad));
{{obj.departmentoobj.nombredepartmento}
您需要使用departmentoeCuiudad对departmentos表进行另一次查找,然后将其添加到ng repeat对象中
$scope.ciudades.departamentoObj = $firebaseObject(rootRef.child(departamentoEciudad));
<td>{{obj.departamentoObj.nombreDepartamento }}</td>
$scope.ciudades.departmentoobj=$firebaseObject(rootRef.child(departmentoecudad));
{{obj.departmentoobj.nombredepartmento}
我很高兴,因为这个拦截器已经解决了,我做到了:
我在数据库中添加了一个名为-nombredepartmento的新字段,当控制器以foreach开头时,我执行一个查询,将$id替换为departmentos.nombre:)
我很高兴,因为这个拦截器已经解决了,我做到了:
我在数据库中添加了一个名为-nombredepartmento的新字段,当控制器以foreach开头时,我执行一个查询,将$id替换为departmentos.nombre:)
提问时不要使用屏幕截图,最好使用小提琴来获得良好的回答。一种方法是扩展$firebaseArray
,以便每次添加/修改城市时,您都可以查看其部门。请参阅AngularFire文档的这一部分:在询问任何问题时,不要使用屏幕截图,最好使用小提琴来获得良好的响应。一种方法是扩展$firebaseArray
,以便每次添加/修改城市时,您都可以查找其部门。请参阅AngularFire文档的这一部分:太好了,你有一些链接或文档可以帮助我吗,谢谢。从AngularFire文档和一些尝试和错误中,你已经了解了你必须的代码,您已经有了一个很好的非规范化数据模型,并且您从其中一个节点检索数据时更正了ReferenceError:在我的代码中没有定义departmentoeCiudad departmentoeCiudad只是$scope.ciudades.departmentoeCiudad的一个变量。我的代码不完整,这取决于你已经编写的代码,这很难确定,因为你还没有发布完整的代码。很好,你有没有一些链接或文档可以帮助我,谢谢。从AngularFire文档和一些尝试和错误中,你已经完成了大部分必须编写的代码,您已经有了一个很好的非规范化数据模型,并且您从其中一个节点检索数据时更正了ReferenceError:在我的代码中没有定义departmentoeCiudad departmentoeCiudad只是$scope.ciudades.departmentoeCiudad的一个变量。我的代码不完整,它取决于您已经编写的代码,这很难确定,因为您还没有发布完整的代码
$scope.replaceRelated = function() {
urlRefCiudad.once("value", function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key(),
refKey = new Firebase(urlItemCiudad+'/'+key);
urlRefCiudad.once("value", function(snapshot) {
var idDtoEciudad = snapshot.val()[key].departamentoEciudad,
urlDtoEciudad = urlRefDto.child(idDtoEciudad);
urlDtoEciudad.once("value", function(snapshot) {
var nombreRelated = snapshot.val().nombreDepartamento;
console.log(nombreRelated);
refKey.update({ RnombreDepartamento: nombreRelated});
});
});
});
});
};