將AngularJS應用程序逐步升級到Angular。
成功升級的關鍵之一是增量執行,由在同一應用程序中並排運行兩個框架,並將AngularJS組件逐個移植到Angular。這樣就可以在不中斷其他業務的情況下升級大型複雜應用程序,因爲可以在一段時間內協同工作並分散工作。 Angular中的upgrade
模塊旨在無縫地進行增量升級。
欲瞭解更多信息,請參閱Angular Developer Guide - Upgrading from AngularJS
也DEMO on PLNKR
見,Angular 2+ can't find Angular 1.X to bootstrap
我不想跑了transpiler另一臺服務器。
試試這個QuickStart example on Plunker無需安裝任何東西。
該譯碼器可以運行在客戶端。這是可能的,但不建議。
<script src="https://unpkg.com/[email protected]?main=browser"></script>
<script src="https://unpkg.com/[email protected]/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
systemjs.config.js
/**
* WEB ANGULAR VERSION
* (based on systemjs.config.js in angular.io)
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
// Copy of compiler options in standard tsconfig.json
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
// paths serve as alias
'npm:': 'https://unpkg.com/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',
// angular bundles
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
// other libraries
'rxjs': 'npm:[email protected]',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ts': 'npm:[email protected]/lib/plugin.js',
'typescript': 'npm:[email protected]/lib/typescript.js',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts',
meta: {
'./*.ts': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
欲瞭解更多信息,請參閱Angular v2 TypeScript QuickStart
轉換角度打字稿例子爲ES6和ES5的JavaScript。
你可以用Angular做什麼TypeScript,你也可以用JavaScript做。從一種語言到另一種語言的翻譯主要是改變組織代碼和訪問Angular API的方式。
欲瞭解更多信息,請參閱Angular Developer Cookbook - TypeScript to JavaScript
只是爲了清楚起見......在transpiler在客戶端* *前被部署到服務器上運行。所以不需要在服務器上設置任何特殊的東西。 – DeborahK