0
votes

I'm trying to use data table with ng2-material library as following:

<md-data-table [selectable]="true">
  <thead>
    <tr md-data-table-header-selectable-row>
      <th class="md-text-cell">Material</th>
      <th>Quantity</th>
      <th>Unit price</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let material of materials" md-data-table-selectable-row [selectable-value]="material.id">
      <td class="md-text-cell">{{ material.name }}</td>
      <td>{{ material.quantity }}</td>
      <td>{{ material.price }}</td>
    </tr>
  </tbody>
</md-data-table>

But Angular2 doesn't recognize the md-data-table tags. I've found out that I don't have the @angular2-material in my node_modules directory. Decided to install it by command:

npm install --save ng2-material

But somehow, some errors appears in the console:

+-- UNMET PEER DEPENDENCY @angular/[email protected] -- [email protected] -- UNMET PEER DEPENDENCY @angular/[email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch okidar\node_modules\fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@ 1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64" })

npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but non e was installed.

Any help appreciated.

1
They're just warnings: do you have have any actual error messages or other problems at build or run time?jonrsharpe
@jonrsharpe Nope, but the angular2-material is not installed in my app folder, it doesnt recognize the tags, so I bet its not downloaded properly... Or that code is deprecated? I used code from this site: justindujardin.github.io/ng2-material/#/components/data-tableMegazord
It's not supposed to be in your app folder, it should be placed in node_modules. How have you added it to your actual project, beyond just the npm install?jonrsharpe
@jonrsharpe Yeah, I have node_modules directory, with a lot of stuff inside. But the data table from that site requires an @angular2-material module, which actually doesnt exist in the node_modules folder. But it supposed to be here, since Ive installed it...Megazord
Isn't @angular2-material a completely different package to ng2-material.jonrsharpe

1 Answers

0
votes

try this command it works for me

$ npm install --save @angular/material @angular/cdk

then

$ ng add @angular/material