Import unable to locate angular2 in beta.1

社会主义新天地 提交于 2019-11-30 19:01:43

问题


The sample code found in AngularJS 2.0 Getting Started with Visual Studio works with alpha.28 version. When I change the scripts from

<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
<script src="https://jspm.io/system@0.16.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js"></script>

to

<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.src.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2.js"></script>

I get an error that says "[local server]/angular2/angular2" is not found.

What has changed since then and how do I configure angular2 to be imported from a CDN?


回答1:


Basically it is causing error from you app.ts file where you have your component resides.

For importing Component, View & bootstrap old version has angular2/angular2 path

import {Component, View, bootstrap} from 'angular2/angular2';

Everyone knows day by day angular2 API has changed rapidly.

So as per current version you need to do angular2/core for importing Component, View

& bootstrap should imported from angular2/platform/browser js

import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {NgFor} from 'angular2/common'; //common things are there in common module

Other than that Rx jx component has been moved out from angular2.dev.js, if you have any code related then you need to include Rx.js separately in your app.

Also you need to include angular2-polyfills.js & es6-shim.js js files to enable support for the older application.

Angular2 Changelog.md



来源:https://stackoverflow.com/questions/34827416/import-unable-to-locate-angular2-in-beta-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!