搜尋

首頁  >  問答  >  主體

angular.js - angularjs 4 元件中的selector是做什麼用的?

@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是做什麼用的?

黄舟黄舟2797 天前913

全部回覆(1)我來回復

  • typecho

    typecho2017-06-13 09:24:51

    selector就是template的容器

    這邊selectorhero-detail,那麼下面的template會顯示在這樣的容器中

    回覆
    0
  • 取消回覆