W Angular2 RC.0 może trzeba dodać
'@angular/router-deprecated': {
main: 'index.js',
defaultExtension: 'js'
},
do swojej packages
w config.js
czy to jeśli chcesz użyj nowego routera:
'@angular/router': {
main: 'index.js',
defaultExtension: 'js'
},
Przykład config.js
z 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);
Pozdrowienia, Najpierw dodałem twoje pierwsze rozwiązanie, ale przyniosły mi nowe błędy. Uważam, że tak czy inaczej lepiej jest przejść na nowy router. Zainstalowałem nowy router i nie wiem jak to działa. Czy możesz podać link do samouczka/api dla nowego routera? Dzięki! :) –
Nie znalazłem jeszcze żadnej osoby. Oto kilka bitów https://github.com/angular/angular/commit/602641d Oto Plunker Obecnie gram z https://plnkr.co/edit/yRKhoOelf2uJ3yAsdIMm?p=info –
Widziałem twój plunker . Wygląda na to, że dekorator @Router łamie oba moje IDE i nie kompiluje. Czy muszę zaktualizować mój kompilator ts lub coś takiego? Dzięki za pomoc! –