显然我不完全了解Angular的ng-show指令如何与$ scope交互。我试图在数组为空时隐藏元素。我的HTML如下:
<h1>Tabs</h1>
<ul ng-hide="tabs.length == 0">
<li ng-repeat="t in tabs">
<img src="{{t.thumbnailurl}}" />
</li>
</ul>
标签是这样的:
Array
0: Object
$$hashKey: "01H"
created: "2013-08-20 20:15:00"
thumbnailurl: "https://s3.amazonaws.com/xxxxx"
__proto__: Object
1: Object
$$hashKey: "01J"
created: "2012-07-09 23:26:49"
thumbnailurl: "https://s3.amazonaws.com/xxxxx"
__proto__: Object
length: 2
__proto__: Array[0]
当我加载页面时,ng-hide在控制台中抛出以下异常,指出匿名函数没有方法'trim'。显然,Angular在内部结构中呕吐。
TypeError: Object function () {
// If the string looks like an identifier, then we can return it as is.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can simply slap some quotes around it.
// Otherwise we must also replace the offending characters with safe
// sequences.
if (ix.test(this)) {
return this;
}
if (/[&<"\/\\\x00-\x1f]/.test(this)) {
return '"' + this.replace(/[&<"\/\\\x00-\x1f]/g, function (a) {
var c = escapes[a];
if (c) {
return c;
}
c = a.charCodeAt();
return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + this + '"';
} has no method 'trim'
at watchFnToHumanReadableString (http://b.gro/campaigns#/tabs/23402:706:30)
at Object.$delegate.__proto__.$watch (http://b.gro/campaigns#/tabs/23402:735:28)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:13829:9
at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:4406:13)
at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:4015:15)
at publicLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:3920:30)
at <error: illegal access>
at Object.Scope.$broadcast (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:8307:28)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:7463:26
at wrappedCallback (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js:6846:59) <ul ng-hide="tabs.length == 0" class="ng-scope"> angular.js:5754
根据ng-hide / show docs的说法,此指令应该非常简单,并接受传递给它的真理/虚假陈述。我只是不确定我在做什么错...
所以,得到这个。注意到这在FF中正确触发后,我开始在Chromium中禁用扩展。事实证明,一旦我禁用了角度调试器插件:https : //chrome.google.com/webstore/detail/angularjs-batarang/ighdmehidhipcmcojjgiloacoafjmpfk,它将正确触发!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句