title: How to get array values from attribute?
body: <p>I am making application in angular 6 and As i am sending and receiving data in dynamic mode, i am in the need to pass and retrieve the array values through attribute for which i have used the following,</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;ul class="list-unstyled" id="list" [attr.parent_id]="123"&gt;
      &lt;li #li class="media p-2 column" *ngFor="let item of items;let i = index;" [attr.items]="item"&gt; {{item.name}} &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>TS:</strong></p>
  
  <pre><code>import { Component, ViewChildren, QueryList, ElementRef } from '@angular/core';
  
  @Component({
    selector: 'my-app',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
    @ViewChildren("li") listElements: QueryList&lt;ElementRef&lt;HTMLLIElement&gt;&gt;;
    name = 'Angular';
    items = [
      { "id": 123, "name": "hello" },
      { "id": 234, "name": "world" }
    ]
    ngAfterViewInit() {
      this.printElements();
      this.listElements.changes.subscribe(_ =&gt; this.printElements());
    }
  
    private printElements() {
      const elements = this.listElements.toArray();
      elements.forEach(element =&gt; {
        console.log(element.nativeElement.getAttribute('items'));
      })
    }
  }
  </code></pre>
  
  <p><strong>Working Stackblitz:</strong></p>
  
  <p><a href="https://stackblitz.com/edit/angular-jndtv1" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-jndtv1</a></p>
  
  <p>Here instead of </p>
  
  <pre><code>console.log(element.nativeElement.getAttribute('items'));
  </code></pre>
  
  <p>(which gives [object object])</p>
  
  <p>If i include JSON.stringify,</p>
  
  <pre><code>console.log(JSON.stringify(element.nativeElement.getAttribute('items')));
  </code></pre>
  
  <p>(gives "[object object]")</p>
  
  <p>Kindly help me to get the array values through the attribute using only <strong>Pure javascript/typescript</strong> without jquery.</p>