angular.js - angularjs 4 组件中的selector是干什么用的?

浏览:29日期:2022-12-18

问题描述

@Component({ selector: ’hero-detail’, template: ` <p *ngIf='hero'>

<h2>{{hero.name}} details!</h2> <p><label>id: </label>{{hero.id}}</p> <p> <label>name: </label> <input [(ngModel)]='hero.name' placeholder='name'/> </p>

</p> `})中的selector是干什么用的?

问题解答

回答1:

selector就是template的容器

这边selector是hero-detail,那么下面的template会显示在<hero-detail></hero-detail>这样的容器中

相关文章: