我建立這樣一個部件:(從樣品)`angular2`如何導出組件?
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?
和導入到另一個模塊:
<script>
System.config({
packages: {
app: {
format: 'register', //what is means?
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
I:
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component' //what it's imports here
bootstrap(AppComponent); //it works.
index.html中
我無法理解背後的邏輯,請幫助我嗎?
在此先感謝。
因此,'import'需要整個文件而不是類。是嗎? – user2024080
從「庫」中導入「模塊名稱」是有意義的,如果你已經學會了像Python這樣的oop語言, 「庫」可能是角度庫如「angular2/core」../ common ..等,否則,你可能導入本地模塊,如「app.component」與../,../../,./這個模式 – mckit