question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create md-table with sort

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

I wanted to implement the md-table with sorting as in the example https://material.angular.io/components/table/overview

What is the current behavior?

Got error:

ERROR TypeError: Cannot read property ‘mdSortChange’ of undefined

<md-table #table [dataSource]="dataSource" mdSort>

...
import {MdSort} from '@angular/material';

@ViewChild(MdSort) sort: MdSort;

    ngAfterViewInit() {
        console.log({SORT:this.sort});
    }

SORT : undefined

What are the steps to reproduce?

Copy example code from https://material.angular.io/components/table/overview

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

“dependencies”: { “@angular/animations”: “^4.2.6”, “@angular/cdk”: “^2.0.0-beta.8”, “@angular/common”: “^4.0.0”, “@angular/compiler”: “^4.0.0”, “@angular/core”: “^4.0.0”, “@angular/forms”: “^4.0.0”, “@angular/http”: “^4.0.0”, “@angular/material”: “^2.0.0-beta.8”, “@angular/platform-browser”: “^4.0.0”, “@angular/platform-browser-dynamic”: “^4.0.0”, “@angular/router”: “^4.0.0”, “core-js”: “^2.4.1”, “rxjs”: “^5.1.0”, “zone.js”: “^0.8.4” }, “devDependencies”: { “@angular/cli”: “1.2.1”, “@angular/compiler-cli”: “^4.0.0”, “@angular/language-service”: “^4.0.0”, “@tуpes/jasmine”: “~2.5.53”, “@tуpes/jasminewd2”: “~2.0.2”, “@tуpes/node”: “~6.0.60”, “codelyzer”: “~3.0.1”, “jasmine-core”: “~2.6.2”, “jasmine-spec-reporter”: “~4.1.0”, “karma”: “~1.7.0”, “karma-chrome-launcher”: “~2.1.1”, “karma-cli”: “~1.0.1”, “karma-coverage-istanbul-reporter”: “^1.2.1”, “karma-jasmine”: “~1.1.0”, “karma-jasmine-html-reporter”: “^0.2.2”, “protractor”: “~5.1.2”, “ts-node”: “~3.0.4”, “tslint”: “~5.3.2”, “typescript”: “~2.3.3” }

Windows 7 x64, Google Chrome 59.0.3071.115

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

47reactions
oryamcommented, Jul 17, 2017

You might forget to import the module : MdSortModule. @see material2/src/demo-app/demo-app-module.ts

10reactions
TomDevoldercommented, Jul 18, 2017

fixed it… bug had nothing to do with the CDK table… the md-table was in a *ngIf (which was set to true, but nonetheless caused an undefined mdSort) I (temporarily) fixed it with an [style.visibility] binding.

*anyboddy suggestions how to solve undefined instances due to an ngIf?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - mysql cannot create table - error 1005 - Stack Overflow
One or both of your tables is a MyISAM table. In order to use foreign keys, the tables must both be InnoDB. (Actually,...
Read more >
Error when ordering by column in related table when using ...
Current behavior: Error: "The order supplied is not unique, so before/after cursors cannot be used. Please ensure the supplied order includes all the...
Read more >
Create and format tables - Microsoft Support
Learn about the many ways to create a table in an Excel worksheet, and how to clear data, formatting, or table functionality from...
Read more >
CREATE TABLE Statement - Apache Impala
The SORT BY columns cannot include any partition key columns for a partitioned table, because those column values are not represented in the...
Read more >
CREATE TABLE AS - Amazon Redshift
Specifies that the data is sorted using a compound key made up of all of the listed columns, in the order they are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found