admin管理员组文章数量:1335175
Hey guys I have just been learning about angular JS and Firebase and for some reason I seem to be getting a Reference Error when I try to call the $timeout function in the following code:
'use strict';
/**
* @ngdoc function
* @name drivenApp.controller:MainCtrl
* @description
* # MainCtrl
* Controller of the drivenApp
*/
angular.module('drivenApp')
.controller('MainCtrl', function ($scope) {
var rootRef = new Firebase('/');
var childRef = rootRef.child('message');
childRef.on('value', function(snapshot){
$timeout(function() {
var snapshotVal = snapshot.val();
console.log(snapshotVal);
$scope.message = snapshot.val();
});
});
});
I get this exact error:
Uncaught ReferenceError: $timeout is not defined(anonymous function) @ main.js:16(anonymous function) @ firebase.js:202gc @ firebase.js:52cc @ firebase.js:30dc @ firebase.js:29h.Kb @ firebase.js:221h.Ld @ firebase.js:189Fh.Ld @ firebase.js:179(anonymous function) @ firebase.js:177zh @ firebase.js:171La.onmessage @ firebase.js:170
Any idea why this might be happening? Thanks, Nick
Hey guys I have just been learning about angular JS and Firebase and for some reason I seem to be getting a Reference Error when I try to call the $timeout function in the following code:
'use strict';
/**
* @ngdoc function
* @name drivenApp.controller:MainCtrl
* @description
* # MainCtrl
* Controller of the drivenApp
*/
angular.module('drivenApp')
.controller('MainCtrl', function ($scope) {
var rootRef = new Firebase('https://vivid-torch-5432.firebaseio./');
var childRef = rootRef.child('message');
childRef.on('value', function(snapshot){
$timeout(function() {
var snapshotVal = snapshot.val();
console.log(snapshotVal);
$scope.message = snapshot.val();
});
});
});
I get this exact error:
Uncaught ReferenceError: $timeout is not defined(anonymous function) @ main.js:16(anonymous function) @ firebase.js:202gc @ firebase.js:52cc @ firebase.js:30dc @ firebase.js:29h.Kb @ firebase.js:221h.Ld @ firebase.js:189Fh.Ld @ firebase.js:179(anonymous function) @ firebase.js:177zh @ firebase.js:171La.onmessage @ firebase.js:170
Any idea why this might be happening? Thanks, Nick
Share Improve this question asked Feb 20, 2016 at 16:51 Nicholas MaddrenNicholas Maddren 1555 silver badges12 bronze badges1 Answer
Reset to default 8You need declare $timeout
to use it same as:
angular.module('drivenApp')
.controller('MainCtrl', function ($scope, $timeout) {
var rootRef = new Firebase('https://vivid-torch-5432.firebaseio./');
var childRef = rootRef.child('message');
childRef.on('value', function(snapshot){
$timeout(function() {
var snapshotVal = snapshot.val();
console.log(snapshotVal);
$scope.message = snapshot.val();
});
});
});
本文标签: javascriptAngularJS amp Firebase 39timeout is not defined39Stack Overflow
版权声明:本文标题:javascript - AngularJS & Firebase '$timeout is not defined' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742252099a2440953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论