如何获取angularJS中具有嵌套数组的对象数组的长度

时间:2016-04-12 11:21:41

标签: arrays angularjs json

我正从具有对象数组的json文件中检索数据,这些对象也包含嵌套对象数组。

以下是示例。

 [
  {
    "systemId": "3jtc99bvzP",
    "systemName": "HTML Basics",
     "defect": [],
    "searchKey": [

      {
        "searchkey": "Dhanasekar_Mohan",
        "searchId": "129391f9",
        "systemName": "HTML Basics",
        "systemId": "3jtc99bvzP"
      },
      {
        "searchkey": "Dhanasekar_Mohan",
        "searchId": "129391f9",
        "systemName": "HTML Basics",
        "systemId": "3jtc99bvzP"
      }
    ],
    "otherDetails": [
      {
        "img": "/MasterPage/img/blog_post3.jpg",
        "description": "<p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">A beginning tag is generally a word surrounded by brackets. The closure tag is surrounded by the same brackets but with a forward slash right after the opening bracket.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">For example, if you want to bold a portion of a sentence, then you would use &lt;b&gt; for the opening tag and &lt;/b&gt; for the closing.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">Let's say you want to bold the word \"Hello!\" in the sentence below. Then your HTML code would look like this:</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\"><em>&lt;b&gt;Hello!&lt;/b&gt;</em><span>&nbsp;</span>My name is Carla.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">The output would be:&nbsp;</p><p align=\"center\" style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;text-align:center;background:white;\"><strong>Hello!</strong><span>&nbsp;</span>My name is Carla.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">Only the word \"Hello!\" is bolded because the tags surround that word. If you wanted to bold the entire sentence, then you would have put the closure tag, &lt;/b&gt;, after the word \"Carla\".&nbsp; Be sure to always include your closing tag because if you forget, your entire page will be affected by the tag.</p><p style=\"margin-bottom:15pt;background:white;\"><a name=\"basic\"><strong><span style=\"text-decoration:underline;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Basic Text &amp; Font Tags</span></span></strong></a><strong></strong></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">New Paragraph:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\"> &lt;p&gt; Starts a new paragraph and creates a blank line between your new paragraph and the one above it.&nbsp;</span></p><p style=\"margin-bottom:21pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">The closing tag is &lt;/p&gt;, but is not mandatory.</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Line Break:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&nbsp;&lt;br&gt;&nbsp; This will break your text to the next line.&nbsp; Two &lt;br&gt; tags is equivalent to one &lt;p&gt; tag.&nbsp;&nbsp;There's no closing tag needed for this one.</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Bold:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\"> &lt;b&gt;&nbsp;&nbsp;Closing tag is &lt;/b&gt;</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Underline:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\"> &lt;u&gt;&nbsp;&nbsp; Closing tag is &lt;/u&gt;</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Italics:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\"> &lt;i&gt;&nbsp;&nbsp; Closing tag is &lt;/i&gt;</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Centering text:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\"> &lt;center&gt;&nbsp; Closing tag is &lt;/center&gt;</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Left aligning text:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;p align=\"left\"&gt; Just use &lt;/p&gt; for the closing tag</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Right aligning text:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;p align=\"right\"&gt; Just use &lt;/p&gt; for the closing tag</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Change text color:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;font color=\"red\"&gt; The ending for any font tag is &lt;/font&gt;&nbsp;</span></p><p style=\"margin-bottom:21pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">If you want more colors, you can also use my&nbsp;</span><a href=\"http://www.2createawebsite.com/build/html.html#colors\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:windowtext;\">hex color code tools</span></a><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">.</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Changing font face:</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&nbsp;&lt;font face=\"Arial\"&gt;</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Change font size:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;font size=\"3\"&gt; (choose between 1 and 7)</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Blinking Text:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;blink&gt;&nbsp; &lt;/blink&gt; (only works in Netscape)</span></p><p style=\"margin-bottom:21pt;background:white;\"><strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Scrolling Text:&nbsp;</span></strong><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">&lt;marquee&gt; &lt;/marquee&gt; (only works in Internet Explorer)</span></p><h2 style=\"margin-top:0in;margin-right:0in;margin-bottom:15.0pt;margin-left:0in;background:white;\"><span style=\"font-size:12.0pt;\">Basic Structure of an HTML Page</span></h2><p style=\"margin-bottom:21pt;background:white;\"><span style=\"font-size:12pt;font-family:'Times New Roman', serif;background-image:initial;background-attachment:initial;background-size:initial;background-origin:initial;background-clip:initial;background-position:initial;background-repeat:initial;\">Here you will see a sample HTML page with the basic structure.</span></p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;html&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;head&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;title&gt;Title that is displayed at the top of your web browser and also used as the title by many search engines&lt;/title&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;meta name=\"description\" content=\"10-15 word description of your site read by some search engines\"&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;meta name=\"keywords\" content=\"main keywords of your site separated by commas. Read by some search engines\"&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;/head&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;body&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;p align=\"left\"&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">This is my new web page. I hope you like it. Please come back and visit again.&nbsp; If you need help creating your web site visit &lt;a href=\"http://www.2createawebsite.com\"&gt;2 Create a Website.com&lt;/a&gt;.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;/p&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;/body&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">&lt;/html&gt;</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">The &lt;html&gt; tag just tells the browser where the HTML starts. It is not necessary to include this tag to get your page to show.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">The &lt;title&gt; tells your browser the title of the page and you<span style=\"font-family:'Tahoma',sans-serif;\">�</span>ll see this text at the very top of your web browser. This is also used by most search engines when indexing your page. Whatever text you have here will be title of your site when displayed in the search engines.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">The &lt;meta name&gt; information is also somewhat useful for some search engines. They may use whatever is in your \"description\" tag to describe your site. Others may randomly take an excerpt of the &lt;body&gt; of your page for a description of your site. The keyword tag may also be helpful with your ranking in some engines. Insert 3 or 4 of your main keywords or keyword phrases separated by commas here.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">A few years ago, the &lt;meta name&gt; information was quite crucial in getting a top listing with the search engines. However, things have changed drastically with the explosion of so many new sites and the fact that many people abused it. I would still recommend using these tags but don<span style=\"font-family:'Tahoma',sans-serif;\">�</span>t expect to get a top ranking because of them.</p><p style=\"margin-top:0in;margin-right:0in;margin-bottom:21.0pt;margin-left:0in;background:white;\">The body of your site should be included inside the &lt;body&gt; tags.</p>",
        "url": ""
      }
    ],
    "noofview": "0", 
    "sybcategory": null,
    "lastmodifieddate": "6-5-2015",
    "lastmodifiedby": "Dhanasekar_Mohan"
  },
  {
    "systemId": "fTxqPf8dqs",
    "systemName": "JQuery",
    "defect": [],
    "searchKey": [

      {
        "searchkey": "Dhanasekar_Mohan",
        "searchId": "327f8fca",
        "systemName": "JQuery",
        "systemId": "fTxqPf8dqs"
      },
      {
        "searchkey": "Dhanasekar_Mohan",
        "searchId": "327f8fca",
        "systemName": "JQuery",
        "systemId": "fTxqPf8dqs"
      }
    ],
    "otherDetails": [
      {
        "img": "/MasterPage/img/blog_post3.jpg",
        "description": "<p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"color:#333333;font-family:'Times New Roman', serif;font-size:12pt;line-height:16.05pt;\">The purpose of jQuery is to make it much easier to use JavaScript on your website.</span><br /></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">The jQuery library contains the following features:</span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">HTML/DOM manipulation</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">CSS manipulation</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">HTML event methods</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Effects and animations</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">AJAX</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Utilities</span></li></ul><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">There are lots of other JavaScript frameworks out there, but jQuery seems to be the most popular, and also the most extendable.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">Many of the biggest companies on the Web use jQuery, such as:</span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Google</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Microsoft</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">IBM</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Netflix</span></li></ul><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">There are several ways to start using jQuery on your web site. You can:</span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Download the jQuery library from jQuery.com</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">Include jQuery from a CDN, like Google</span></li></ul><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery has several methods for CSS manipulation. We will look at the following methods:</span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">addClass() - Adds one or more classes to the selected elements</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">removeClass() - Removes one or more classes from the selected elements</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">toggleClass() - Toggles between adding/removing classes from the selected elements</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">css() - Sets or returns the style attribute</span></li></ul><ul><li><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">AJAX = Asynchronous JavaScript and XML.</span></li><li><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">In short; AJAX is about loading data in the background and display it on the webpage, without reloading the whole page.</span></li><li><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">Examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook tabs.</span></li><li><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery provides several methods for AJAX functionality.</span></li><li><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!</span></li></ul><p style=\"text-align:justify;\"><span style=\"font-size:12.0pt;line-height:107%;font-family:'Times New Roman',serif;\">&nbsp;</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">The jQuery syntax is tailor made for&nbsp;<strong>selecting</strong>&nbsp;HTML elements and performing some&nbsp;<strong>action</strong>&nbsp;on the element(s).</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">Basic syntax is:&nbsp;<strong>$(<em>selector</em>).<em>action</em>()</strong></span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">A $ sign to define/access jQuery</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">A (<em>selector</em>) to \"query (or find)\" HTML elements</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">A jQuery&nbsp;<em>action</em>() to be performed on the element(s)</span></li></ul><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">Examples:</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">$(this).hide() - hides the current element.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">$(\"p\").hide() - hides all &lt;p&gt; elements.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">$(\".test\").hide() - hides all elements with class=\"test\".</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">$(\"#test\").hide() - hides the element with id=\"test\".</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery selectors allow you to select and manipulate HTML element(s).</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">jQuery selectors are used to \"find\" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more. It's based on the existing&nbsp;</span><a href=\"http://www.w3schools.com/cssref/css_selectors.asp\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">CSS Selectors</span></a><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">, and in addition, it has some own custom selectors.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">All selectors in jQuery start with the dollar sign and parentheses: $().</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">All the different visitor's actions that a web page can respond to are called events.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">An event represents the precise moment when something happens.</span></p><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">Examples:</span></p><ul type=\"disc\"><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">moving a mouse over an element</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">selecting a radio button</span></li><li style=\"color:#333333;text-align:justify;line-height:16.05pt;tab-stops:list .5in;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;\">clicking on an element</span></li></ul><p style=\"margin-bottom:7.5pt;text-align:justify;line-height:16.05pt;background:white;\"><span style=\"font-size:12.0pt;font-family:'Times New Roman',serif;color:#333333;\">The term&nbsp;<strong>\"fires\"</strong>&nbsp;is often used with events. Example: \"The keypress event fires the moment you press a key\".</span></p>",
        "url": ""
      }
    ],
    "noofview": "0",
    "sybcategory": null,
    "lastmodifieddate": "6-5-2015",
    "lastmodifiedby": "Dhanasekar_Mohan"
  }]

这里有两个基础数组中的对象,它本身包含两个对象数组。

我试图用

找到它的长度
var l = $scope.compData.length;

在这里,我应该给那些没有工作的人。

我已将数据存储在$ scope.compData

这是angularJs代码

.controller('gridListDemoCtrl', function ($scope, Bsmart) {
      $scope.compData = {};
      Bsmart.get().then(function (msg) {
          $scope.compData = msg.data;

      });

      days();

      function days() {
          var currentDate = new Date();
          var cd = currentDate.getDate();
          var l;
          l = $scope.compData.length;
          for(var i=0;i<l;i++)
          {
              $scope.compData[i].lastmodifieddate = l;
          }

      }



  });

任何帮助都会很明显。

1 个答案:

答案 0 :(得分:0)

这里:

  Bsmart.get().then(function (msg) {
      $scope.compData = msg.data;

  });

您作为参数提供的功能将异步执行。但是,在你的主线程中,你立即调用days();,它在$scope.compData上执行操作,这仍然是一个空对象(当你初始化它时)。

您应该在回调函数中调用days()

  Bsmart.get().then(function (msg) {
      $scope.compData = msg.data;
      days();

  });