当元素添加到 AngularJS 中的范围时,如何在所有设备上播放声音
How can I play a sound on all devices when an element is added to a scope in AngularJS
我想通过发出哔声来通知网络应用程序的所有用户新元素已添加到 $scope。因此,当一个新元素出现在 ng-repeat 中时,应用程序会发出哔哔声。
我可以在添加元素的屏幕上很容易地做到这一点(如下所示),但无法找到如何为每个人播放蜂鸣声。
$scope.beep = function(){
beep.play();
};
$scope.addMeal = function(meal) {
if(meal.food != null && meal.calories != null){
$scope.todaymeals.$add(meal);
if(angular.isDefined($scope.meal)){
delete $scope.meal;
beep.play();
}
}
}
您可以轻松调用 onchildadded 方法:
ref.on('child_added', function(childSnapshot, prevChildKey) {
beep.play(); //In Your case
});
我想通过发出哔声来通知网络应用程序的所有用户新元素已添加到 $scope。因此,当一个新元素出现在 ng-repeat 中时,应用程序会发出哔哔声。 我可以在添加元素的屏幕上很容易地做到这一点(如下所示),但无法找到如何为每个人播放蜂鸣声。
$scope.beep = function(){
beep.play();
};
$scope.addMeal = function(meal) {
if(meal.food != null && meal.calories != null){
$scope.todaymeals.$add(meal);
if(angular.isDefined($scope.meal)){
delete $scope.meal;
beep.play();
}
}
}
您可以轻松调用 onchildadded 方法:
ref.on('child_added', function(childSnapshot, prevChildKey) {
beep.play(); //In Your case
});