In Angular2 rc.0 potrebbe essere necessario aggiungere
'@angular/router-deprecated': {
main: 'index.js',
defaultExtension: 'js'
},
al vostro packages
in config.js
o questo se si desidera utilizzare il nuovo router:
'@angular/router': {
main: 'index.js',
defaultExtension: 'js'
},
Esempio config.js
dal rc.0
Plunker
(function(global) {
var ngVer = '@2.0.0-rc.0'; // lock in the angular package version; do not let it float to current!
//map tells the System loader where to look for things
var map = {
'app': 'src', // 'dist',
'rxjs': 'https://npmcdn.com/[email protected]',
'angular2-in-memory-web-api': 'https://npmcdn.com/angular2-in-memory-web-api' // get latest
};
//packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'app.ts', defaultExtension: 'ts' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { defaultExtension: 'js' },
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router-deprecated',
'@angular/testing',
'@angular/upgrade',
];
// add map entries for angular packages in the form '@angular/common': 'https://npmcdn.com/@angular/[email protected]'
packageNames.forEach(function(pkgName) {
map[pkgName] = 'https://npmcdn.com/' + pkgName + ngVer;
});
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function(pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
},
map: map,
packages: packages
}
// filterSystemConfig - index.html's chance to modify config before we register it.
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
System.config(config);
})(this);
fonte
2016-05-03 09:21:20
Saluti, Prima ho aggiunto la prima soluzione, ma mi ha generato nuovi errori. Credo che sia meglio passare al nuovo router al più presto. Ho installato il nuovo router e non so come funziona. Potrebbe per favore collegarmi un tutorial/api per il nuovo router? Grazie! :) –
Non ne ho ancora trovato nessuno. Ecco alcuni bit https://github.com/angular/angular/commit/602641d Ecco un Plunker Attualmente sto giocando con https://plnkr.co/edit/yRKhoOelf2uJ3yAsdIMm?p=info –
Ho visto il tuo plunker . Sembra che il decorer @Router rompa il mio IDE e non si compili. Devo aggiornare il mio compilatore ts o qualcosa del genere? Grazie per tutto l'aiuto! –