2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【備忘録】Angularのselectorの種類

Posted at

Angularには以下の三つのディレクティブの種類があります。
・コンポーネント
・構造ディレクティブ
・属性ディレクティブ
ディレクティブはselectorを使うことで効果を及ぼす対象を決めることができます。
セレクターには三つ種類があります。
##要素セレクター

@Component({
    selector: 'app-element',
    template:  './element.component.html',
    styleUrls: ['./element.component.css']
})

以下のHTMLに対して有効。

<app-element></app-element>

##属性セレクター

@Component({
    selector: '[app-element]',
    template:  './element.component.html',
    styleUrls: ['./element.component.css']
})

以下のHTMLに対して有効。

<div app-element></div>

##クラスセレクター

@Component({
    selector: '.app-element',
    template:  './element.component.html',
    styleUrls: ['./element.component.css']
})

以下のHTMLに対して有効。

<div class="app-element"></div>
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?