angular2 - pipe error
<p>I have this <code>PipeGalleryFilter.ts</code>:</p>

<pre><code>import { Pipe,Injectable,PipeTransform } from '@angular/core';
@Pipe({
    name: 'galleryfilter',
    pure: false
})
@Injectable()
export class PipeGalleryFilter implements PipeTransform {
    transform(items: any[], args: any[]): any {
        return items.filter(item =&gt; item.type.indexOf(args[0].type) !== -1);
    }
}///@@
</code></pre>

<p>then I add it to my <code>Gallery</code>:</p>

<p><strong>html</strong></p>

<pre><code>&lt;masonry-brick class="brick50" *ngFor="let brick of bricks | galleryfilter: gallery_args"&gt;
  &lt;img src="{{brick.img}}" alt=""&gt;
&lt;/masonry-brick&gt;
</code></pre>

<p><strong>ts</strong></p>

<pre><code>gallery_args = {type: 'magazine'};

bricks = [
     {title: 'Brick 1',img:"assets/img/img003.jpg",type: "magazine"},
     {title: 'Brick 2',img:"assets/img/img004.jpg",type: "magazine"},
     {title: 'Brick 3',img:"assets/img/img005.jpg",type: "newspaper"},
     {title: 'Brick 4',img:"assets/img/img003.jpg",type: "newspaper"},
     {title: 'Brick 5',img:"assets/img/img004.jpg",type: "newspaper"},
     {title: 'Brick 6',img:"assets/img/img005.jpg",type: "newspaper"},
     {title: 'Brick 1',img:"assets/img/img003.jpg",type: "movies"},
     {title: 'Brick 2',img:"assets/img/img004.jpg",type: "commercials"}, 
     {title: 'Brick 3',img:"assets/img/img005.jpg",type: "commercials"},
     {title: 'Brick 4',img:"assets/img/img003.jpg",type: "commercials"},
     {title: 'Brick 5',img:"assets/img/img004.jpg",type: "lifestyle"},
     {title: 'Brick 6',img:"assets/img/img005.jpg",type: "lifestyle"}
   ];
</code></pre>

<p>But I keep getting:</p>

<blockquote>
  <p>EXCEPTION: Error in ./Gallery class Gallery - inline template:22:39
  caused by: Cannot read property 'type' of undefined</p>
</blockquote>

<p>I kind of suspect it has something to do with the line <code>return items.filter(item =&gt; item.type.indexOf(args[0].type) !== -1);</code>, but I am not sure how to get it right.</p>

<p>How can I resolve this?</p>