Note that there are some explanatory texts on larger screens.

plurals
  1. POError with AngularJS ng-hide
    primarykey
    data
    text
    <p>Apparently i don't fully understand how Angular's ng-show directive interacts with the $scope. I'm trying to hide an element when an array is empty. my html is as follows:</p> <pre><code>&lt;h1&gt;Tabs&lt;/h1&gt; &lt;ul ng-hide="tabs.length == 0"&gt; &lt;li ng-repeat="t in tabs"&gt; &lt;img src="{{t.thumbnailurl}}" /&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>tabs is this:</p> <pre><code>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] </code></pre> <p>When i load my page, ng-hide throws the following exception in the console stating the anonymous function has no method 'trim'. Obviously Angular is puking somewhere in the internals. </p> <pre><code>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 (/[&amp;&lt;"\/\\\x00-\x1f]/.test(this)) { return '"' + this.replace(/[&amp;&lt;"\/\\\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 &lt;error: illegal access&gt; 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) &lt;ul ng-hide="tabs.length == 0" class="ng-scope"&gt; angular.js:5754 </code></pre> <p>According to the ng-hide/show docs, this directive should be pretty straight forward and accept truthy/falsy statements that are passed to it. I'm just not sure what i'm doing wrong here....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload