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

前端 未结 6 1285
甜味超标
甜味超标 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条回答
  •  自闭症患者
    2020-12-10 04:15

    I got this error with angular RC1 when I was injecting FormBuilder inside the constructor like this:

    export class App {
      constructor(public formBuilder: FormBuilder) {}
    }
    

    But I didn't import it previously! Just add it solves the problem:

    import { FormBuilder } from '@angular/common'

提交回复
热议问题