How to fix Angular 2 `Uncaught (in promise): TypeError: Cannot read property 'query' of null`?

前端 未结 6 1293
甜味超标
甜味超标 2020-12-10 03:36

I\'ve been using the Heroes tutorial in the Angular 2 docs to experiment. However, I\'ve come to a point that I don\'t understand what\'s happening with this error:

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 04:10

    Try with these compilerOptions in "tsconfig.json". It worked for me (Version 2.0.0-rc.1 of angular).

    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true   },
    

    I had the same problem with injectables (same error) and the fix did the trick for services but not for http. I modified my options based on a tutorial from ng-book2 and it finally worked.

提交回复
热议问题