TypeError:dbg在angularjs中未定义 [英] TypeError: dbg is undefined in angularjs

查看:106
本文介绍了TypeError:dbg在angularjs中未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习angularjs并从以下教程开始 - 此处



这是我的index.jsp -

 <!doctype html> 
< html lang =enng-app =phoneCatApp>
< head>
< title>角度范例< / title>
< script type =text / javascriptsrc =angular / angular.min.js>< / script>
< script type =text / javascriptsrc =app / js / controllers.js>< / script>
< / head>
< body ng-controller =phoneListCtrl>
搜索: -
< input ng-model =query/>排序:
< select ng-model =orderProp>
< option value =name>按字母顺序< / option>
< option value =age>最新< / option>
< option value = - age>最旧< / option>
< / select>
< p>手机总数:{{phones.length}}< / p>
< ul>
< li ng-repeat =phone in phone | filter:query | orderBy:orderProp>< span> {{phone.name}}< / span>
< p> {{phone.snippet}}< / p>< / li>
< / ul>
< / body>
< / html>

这个版本的controller.js的工作原理 -

  var phonecatApp = angular.module('phoneCatApp',[]); 
phonecatApp.controller('phoneListCtrlOld',function($ scope){
$ scope.phones = [{$ b $'name':'Nexus S',
'snippet': 'Nexus S.快速获得更快速度',
'age':1
},{
'name':'Motorola XOOM™with Wi-Fi',
'下一代平板电脑,
'age':2
},{
'name':'MOTOROLA XOOM™',
'snippet' :'Next,Next Generation tablet。',
'age':3
}];
$ scope.orderProp ='age';
});

但是在下一步中,我尝试使用ajax调用获取这个json数据,所以控制器看起来像这样 - / p>

  var phonecatApp = angular.module('phoneCatApp',[]); 
phonecatApp.controller('phoneListCtrl',function($ scope,$ http){
$ http.get('app / js / phones.json')。success(function(data){
$ scope.phones = data;
});
$ scope.orderProp ='age';
});

但是这给了我以下错误 -



TypeError:dbg未定义。 debuggerLib.js(第530行)

我可以在firebug中看到ajax调用发生在代码304 Not Modified中。我可以看到数据作为回应。但响应内容类型不是json。



请仔细检查并说出问题所在?我错过了任何包含js文件或其他东西。

解决方案

我有这个相同的错误, a 原因。我无法确定这是否是您的同样原因。



重新启动Firefox,重新启动电脑,移除Firebug,重新安装,优化,运行注册表清理等 - 没有任何帮助。我在debuggerLib.js第556行错误,dbg未定义。



然而,事实证明,我已经安装了Firebug,并且创建了一个目录我的漫游配置文件:

  C:\ Users \Leonardo\AppData\Roaming\Mozilla\Firefox\ Profiles \Leonardo.Serni\firebug 

在该目录中有很多JSON文件,但他们都没有日期今天,这是当我删除并重新安装Firebug。所以我想知道,如果新的 Firebug正在从这个目录中加载一些过时的东西?。



我关闭Firefox,将目录从firebug改为bugfire,重新打开Firefox。



Firebug运行良好,错误消失。我做了同样的事情,没有重命名目录,错误没有消失,所以我相信我的假设是正确的。



该目录已被重新创建,但现在只有两个文件 - annotations.json和breakpoints.json,均为0字节。可能有一天我会尝试添加旧目录中的文件,以查看错误何时返回。



更新(感谢DevNull的评论)



可能没有必要核对整个目录。确认 annotations.json 文件的长度为零。如果不是,则在Firefox未运行时将其重命名为 annotations.old






我开始怀疑 dbg 实际上是调试Firebug本身,并且我们没有定义它,因为我们不是萤火虫开发者。它与调试我们的脚本的Firebug调试器无关。


I am learning angularjs and following tutorial from - here

Here is my index.jsp -

<!doctype html>
<html lang="en" ng-app="phoneCatApp">
<head>
<title>Angular Example</title>
<script type="text/javascript" src="angular/angular.min.js"></script>
<script type="text/javascript" src="app/js/controllers.js"></script>
</head>
<body ng-controller="phoneListCtrl">
    Search : -
    <input ng-model="query"/> Sort by:
    <select ng-model="orderProp">
        <option value="name">Alphabetical</option>
        <option value="age">Newest</option>
        <option value="-age">Oldest</option>
    </select>
    <p>Total number of phones: {{phones.length}}</p>
    <ul>
        <li ng-repeat="phone in phones | filter:query | orderBy:orderProp"><span>{{phone.name}}</span>
            <p>{{phone.snippet}}</p></li>
    </ul>
</body>
</html>

this version of controller.js works -

var phonecatApp = angular.module('phoneCatApp', []);
    phonecatApp.controller('phoneListCtrlOld', function($scope) {
        $scope.phones = [ {
            'name' : 'Nexus S',
            'snippet' : 'Fast just got faster with Nexus S.',
            'age' : 1
        }, {
            'name' : 'Motorola XOOM™ with Wi-Fi',
            'snippet' : 'The Next, Next Generation tablet.',
            'age' : 2
        }, {
            'name' : 'MOTOROLA XOOM™',
            'snippet' : 'The Next, Next Generation tablet.',
            'age' : 3
        } ];
        $scope.orderProp = 'age';
    });

but in the next step i tried fetching this json data with ajax call so controller look like this -

var phonecatApp = angular.module('phoneCatApp', []);
phonecatApp.controller('phoneListCtrl', function($scope, $http) {
    $http.get('app/js/phones.json').success(function(data) {
        $scope.phones = data;
    });
    $scope.orderProp = 'age';
});

But this gives me following error -

TypeError: dbg is undefined. debuggerLib.js (line 530)

I can see in firebug the ajax call is happening with code 304 Not Modified. and i can see data in response. but response content type is not json.

Please look into it and say what is the problem? Am i missing any js file to include or something else.

解决方案

I have had this same error, and after some head scratching found a cause. I can't be sure whether this is your same cause.

Restarting Firefox, rebooting the PC, removing Firebug, reinstalling, optimizing, running registry clean, etc. -- nothing helped. I got error in debuggerLib.js line 556, dbg being undefined.

However, it turns out that I have installed Firebug back in the days, and it created a directory in my Roaming profile:

C:\Users\Leonardo\AppData\Roaming\Mozilla\Firefox\Profiles\Leonardo.Serni\firebug

In that directory there is a lot of JSON files, but none of them dated today, which is when I removed and reinstalled Firebug. So I wondered, "What if the new Firebug is loading something obsolete from this directory?".

I closed Firefox, renamed the directory from "firebug" to "bugfire", reopened Firefox.

Firebug is running perfectly and the error has disappeared. I had done the same thing without renaming the directory and the error did not disappear, so I'm confident that my hypothesis was correct.

The directory has been re-created, but there are now only two files in there - "annotations.json" and "breakpoints.json", both 0 bytes in size. Possibly some day I'll try adding the files from the old directory to see when the error comes back.

Update (thanks to DevNull's comment)

Possibly it is not necessary to nuke the whole directory. Verify that the annotations.json file is zero length. If it is not, just rename it to annotations.old while Firefox is not running.


I'm beginning to suspect that the dbg is actually debugging Firebug itself, and we do not have it defined because we aren't Firebug developers. It has nothing to do with the Firebug debugger that debugs our scripts.

这篇关于TypeError:dbg在angularjs中未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆