Io sono la creazione di un componente come questo: (dal campione)Come `angular2` esporta un componente?
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: '<h1> ~ My First Angular 2-0 App By Gulp Automation ~ </h1>'
})
export class AppComponent { } //what it is exporting here?
e l'importazione a un altro modulo:
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component' //what it's imports here
bootstrap(AppComponent); //it works.
in index.html:
<script>
System.config({
packages: {
app: {
format: 'register', //what is means?
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
I non sono in grado di capire la logica dietro, qualcuno mi aiuta per favore?
grazie in anticipo.
quindi, "import' prende l'intero file anziché la classe. è? – user2024080
importare "nome modulo" da "libreria" ha senso se hai imparato oop come python, "library", magari libreria angolare come "angular2/core" ../ common .. ecc., Altrimenti potresti importare local modulo come "app.component" con ../, ../../, ./ questo modello – mckit