我已阅读所有其他相同问题的帖子,但无法解决问题。
如果我在浏览器中编译为javascript,我会在@ angular / http和@ angular / core中得到两个404错误。
当我首先将配置文件设置为transpile时,我在system.config.js中遇到了编译错误:
' ReferenceError:系统未定义'在这一行
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
我从快速入门指南和Tour of Heros Http示例开始了这个项目。
将我的所有文件与快速启动中的文件进行比较后,我将快速启动文件复制到我的项目中。
我确定我错过了一些基本的东西,但已经走到了尽头。 仅供参考:我是Angular和Angular2的新手。使用WebStorm进行开发和编译。
这是index.html和systemjs.config.js
//system.config.js
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
};
var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
}
// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}
// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);
var config = {
map: map,
packages: packages
};
System.config(config);
})(this);

<!DOCTYPE html>
<html>
<head>
<title>Generic Form</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="forms.css">
<!-- Polyfill(s) for older browsers -->
<script src="https://npmcdn.com/core-js/client/shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
&#13;
import { Injectable } from '@angular2/core';
import { Http, Response } from '@angular2/http';
import { Headers, RequestOptions } from '@angular2/http';
import { Observable } from 'rxjs/Observable';
请告诉我其他文件会有什么帮助。我很感激任何见解!
答案 0 :(得分:1)
当前版本的角度2使用&#39; @ angular&#39;而不是beta使用&#39; angular2&#39;
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';