Module '“angular2/angular2”' has no exported member 'For'

后端 未结 2 877
天涯浪人
天涯浪人 2021-01-05 08:05

I am following the tutorial on the official Angular2 website.

https://angular.io/docs/js/latest/guide/displaying-data.html

Here is my .ts file:



        
2条回答
  •  一整个雨季
    2021-01-05 08:39

    Your issue is that the documentation is not in sync. If you followed the documentation for installation recently then it would have installed the typings for latest version alpha26, which has a lot of broken changes. And the documentation uses a23 version with that version of code. You can either

    1) Update your typings to older version that matches v23, which you can find it here. Copy the contents and replace it in ./typings/angular2/angular2.d.ts.

    2) Upgrade your angular script to alpha 26 and fix couple of things.

    • For is now NgFor, If is now NgIf
    • *for is now *ng-for, *if is now *ng-if ...
    • injectables (if you intend to use in your directive settings) is now appInjector

    • install typings for es6-promise, rx and rx-lite using the same tsd query xxx --action install command.

      Demo - 23

      Demo - 26

    You could also use the startup from angular-class webpack starter.

提交回复
热议问题