{"id":264,"date":"2017-07-21T11:43:00","date_gmt":"2017-07-21T09:43:00","guid":{"rendered":"https:\/\/celilsemi.erkiner.com\/blog\/?p=264"},"modified":"2020-05-28T11:46:30","modified_gmt":"2020-05-28T09:46:30","slug":"your-first-angular-component","status":"publish","type":"post","link":"https:\/\/celilsemi.erkiner.com\/blog\/your-first-angular-component\/","title":{"rendered":"Your first Angular Component"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Creating an Angular Component<\/h1>\n\n\n\n<p>Angular-CLI creates a component with all required configuration with a simple command; `ng g c name-of-your-component`. This will create the component bundled in a folder that has the same name with your component name.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7-1024x154.png\" alt=\"\" class=\"wp-image-265\" width=\"884\" height=\"133\" srcset=\"https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7-1024x154.png 1024w, https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7-300x45.png 300w, https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7-768x116.png 768w, https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7-1536x231.png 1536w, https:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2020\/05\/image-7.png 1879w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/figure><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">The Component Class<\/h1>\n\n\n\n<p>Angular-CLI generated the component class in the typescript file. @Component decorator contains the connections for the template and the style files.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application\/typescript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;TypeScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;typescript&quot;}\">import { Component, OnInit } from '@angular\/core';\n\n@Component({\n  selector: 'app-test-component',\n  templateUrl: '.\/test-component.component.html',\n  styleUrls: ['.\/test-component.component.css']\n})\nexport class TestComponentComponent implements OnInit {\n\n  constructor() { }\n\n  ngOnInit() {\n  }\n\n}<\/pre><\/div>\n\n\n\n<p>Other than the basic component features, this class is also implementing OnInit interface from Core library.<\/p>\n\n\n\n<p>Angular-CLI also imported the new component and added it in declarations array of the AppModule.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating an Angular Component Angular-CLI creates a component with all required configuration with a simple command; `ng g c name-of-your-component`. This will create the component bundled in a folder that has the same name with your component name. The Component Class Angular-CLI generated the component class in the typescript file. @Component decorator contains the connections [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[22,4,48,46],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-front-end","tag-angular","tag-javascript","tag-spa","tag-typescript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":1,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}