【发布时间】:2015-06-23 23:16:18
【问题描述】:
我有一个 Angularjs htmlfile,它列出了来自 firebase 的数据。来自 firebase 的数据使用 ng-repeat 呈现。页面加载时,会显示数据。
试图弄清楚如何在将孩子添加到数据集时触发事件。
Firebase web api 导致以下代码:
var ref = new Firebase("https://test.firebaseio.com/test");
$scope.test= $firebaseArray(ref);
ref.on('child_added', function (childSnapshot, prevChildKey) {
function_to_execute();
});
问题是function_to_execute() 在pageload 以及添加的每个子项上都会触发。
有没有办法加载数据集,只有在加载数据集后实际添加child时才触发函数?
【问题讨论】:
-
你能添加更多代码吗?您现在显示的代码是在控制器中还是在其他地方?
标签: angularjs firebase angularfire