0

i am working on an angular2 application where i am using grid list module for creating grids. i have used grid tile tag within the grid list tag for running a for loop but while running the test, it throws up an error stating : template parse error: md-grid-tile' is not a known element i have included the MdGridListModule in my module.ts file. The html part where i am using the tags looks like this :

<div class="col-md-8">
      <div class="layout">
        <h2 >{{title}}</h2>
        <md-grid-list class="grid" cols="3">
          <md-grid-tile class="tile" *ngFor="let block of gs.blocks; let i = index" (click)="playerClick(i)"><i [class]="block.symbol == 'done' ? 'material-icons tick' : 'material-icons cross'">{{ block.symbol }}</i></md-grid-tile>
        </md-grid-list>
      </div>
    </div> 
Rehan Aziz
  • 107
  • 2
  • 14
  • Be more specific on where you get the error: tests or normal run. If it's tests, which I assume, you should recreate the module for the test class by importing the used components. – BogdanC Sep 11 '17 at 15:57
  • You need to add `MdGridListModule` in you module imports. – FAISAL Sep 11 '17 at 15:57
  • @BogdanC i get the error while running the tests. during normal run, the app is running fine. What do you mean by recreating the module for test – Rehan Aziz Sep 11 '17 at 16:01
  • The main idea is that a test class is an 'empty' class, not having all the bindings your component has when running the app, so you have to recreate the structure on your test class. Look at the answer I gave [here](https://stackoverflow.com/a/44811997) to have more details. – BogdanC Sep 11 '17 at 16:44

1 Answers1

1

I had not imported the MdGridListModule in my test files where i had created the test. I imported that and from there on it worked fine. All the components of Angular Material had to be imported in test file as well similar to as they are imported in module file.

Rehan Aziz
  • 107
  • 2
  • 14