Angular 2: Cannot find name 'Subscription'

前端 未结 1 993
萌比男神i
萌比男神i 2021-02-12 01:00

When trying to set the type of an attribute I get the error Cannot find name \'Subscription\'. From which package do I import it from?

import { Comp         


        
1条回答
  •  北恋
    北恋 (楼主)
    2021-02-12 01:57

    You have to import it like this:

    import { Subscription } from 'rxjs';
    

    ORIGINAL ANSWER

    import { Subscription } from 'rxjs/Subscription';
    

    Take a look here: https://angular.io/docs/ts/latest/guide/router.html and there are several plunker's linked in that documentation.

    0 讨论(0)
提交回复
热议问题