In any component selector contains an
element which make the component reusable. By using the selector element, we
can call the component as a html tag in any other components view template.
There three way to define selector
·
As an
element
·
As a style
class
·
As an
attribute
Below is the example which demonstrates
all possible ways
Selector
as Element
import { Component, OnInit } from '@angular/core';
@Component({
selector 'app-server',
templateUrl
'./server.component.html',
styleUrls
['./server.component.css']
})
export class ServerComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<div class="contaner">
<div class="row">
<div class="col-xs-12">
<h3>Server Details</h3>
<hr>
</div>
</div>
<app-servers></app-servers>
</div>
Selector as Attribute
import { Component, OnInit } from '@angular/core';
@Component({
selector '[app-servers]',
templateUrl
'./servers.component.html',
styleUrls
['./servers.component.css']
})
export class ServersComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<div class="contaner">
<div class="row">
<div class="col-xs-12">
<h3>Server Details</h3>
<hr>
</div>
</div>
<!-- <app-servers></app-servers> -->
<div app-servers></div>
</div>
Selector as Class
import { Component, OnInit } from '@angular/core';
@Component({
//selector
'app-servers', --- As element
//selector
'[app-servers]', --- As Attribute
selector
'.app-servers', // As Class
templateUrl
'./servers.component.html',
styleUrls
['./servers.component.css']
})
export class ServersComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<div class="contaner">
<div class="row">
<div class="col-xs-12">
<h3>Server Details</h3>
<hr>
</div>
</div>
<!-- <app-servers></app-servers> -->
<!-- <div app-servers></div> -->
<div class="app-servers"></div>
</div>
Nice informative blog, it shares more intresting information. This blog is useful to me.
ReplyDeletePHP Training in Bangalore
PHP Training in Chennai
PHP Course in Bangalore
PHP Training Institute in Bangalore
PHP Classes in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
DOT NET Training in Bangalore
Data Science Course in Chennai
Nice article with lot of valuable information. AngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery
ReplyDeletekralbet
ReplyDeletebetpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
betmatik
R42NK
شركة مكافحة حشرات بالدمام pElbim13Co
ReplyDeleteشركة مكافحة الصراصير بالدمام gCkxFGvW8T
ReplyDelete