export class AppComponent {}
我也export了HeroComponent模块,然后在app.component一开始就import进来,然后在directive加入这些模块。然后template才能识别相应的selector???
不是很明白这句话,我引入的是HeroComponent里的类吗。然后directive之后,我能怎么用?是继承他的类吗
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
import HeroComponent...
@Component({
directive:[HeroComponent]
})
class AppComponent{}
import只有一个作用,就是把类,变量或者其他东西引入进来,import本身只保证当类需要的时候,存在,可用。
directives的作用就是告诉模版渲染引擎某个标签有特殊意义,当前template渲染的时候,如果识别到directive内指定的标签就自动调用相应的组件,填充这个标签。