Skip to main content

#3 Angular 8 tutorial in hindi | generate components and Component struc...

                 



How to create a Component in Angular 8

To create component in Angular we can use 
ng generate component "component name" command from Angular CLI.
Note:- you can do so : ng  g  c  user  –spec=false  ( it will not generate .spec file).
let’s see what this command is doing:
ng : stands for angular CLI object.
generate: is used to generate any file (you can also use g (short name) instead of generate).
component: it means we want to generate component(you can also use c(short name) instead of component).






Component Structure

Template :-  It is the view layout of the component , it tell the component what would be render for view
Class :-  It is component class that will have properties and methods that will use by view
MetaData:- This provide additional information to angular about component by Decorator, Metadata tells Angular how to process a class


#Class

In Angular we create  class like with class keyword followed by className (here it is infoComponent), here we have used export keyword that is ES6 module system. Export keyword here mark this class as public so that we can use it in other files by importing it .


#MetaData:-


Typescript class will not act like a Angular Component until we don’t attach additional information with metadata and to add metadata we use Decorators.

Decorators are the methods which start with @ symbol. So in this @Component is a decorator which is taking object ({} ) as argument which will allow us to pass metadata.

@Component() decorators will have lot of keys that will be used to define our component.


selector : selector key is used to define the tag name for the component . Now we can call app-user like a custom html tag "app-user" from any html template

templateUrl: Every Component will have a attached template that will work like a view . So whenever this component will render it will display view to the user and that view will come from this template file

styleUrls: Every Component have their own style that will come from file which you will mention in styleUrls. It takes array as value so we can pass multiple css files

@Component is a predefined decorator which we need to import from @angular/core library.



Comments

Popular posts from this blog

#Angular 10 #Star #rating example | Star Review System in angular by #Te...

           In this video, we build a five-star review system with #Angular10 . #Angular 10 #Star #rating example | Star Review System in angular by #Testycodeiz . rating system, #Angular 10 #Star #rating example,angular star rating,angular star rating component,star rating in angular,star rating in angular 8,Star Review System in angular,angular by #Testycodeiz ,angular rating,angular rating star,angular 4 star rating,angular 5 star rating,angular 6 star rating,angular 7 star rating,angular 8 star rating,angular 9 star rating sytem,angular 10 star rating system,angular star rating by testy codeiz,testycodeiz angular

#8 how to create RESTful API with nodejs in hindi | PUT method in REST A...

                    how to create #RESTful API with #nodejs in hindi | #PUT method in REST API in #nodejs by Ashish 😮 Use PUT when you want to modify a singular resource which is already a part of resources collection. PUT replaces the resource in its entirety. Use PATCH if request updates part of the resource. Generally, in practice, always use PUT for #UPDATE operations. Handling PUT requests PUT requests will be used to make updates to existing resources. It’s important to note that #PUT is used to replace the entire resource – it doesn’t do partial updates (I will show you how to do this with PATCH in the future).

mongoDB,How to download mongoDB, How to Install MongoDB, MongoDB for Ang...

           mongoDB,How to download mongoDB, How to Install MongoDB, MongoDB for Angular, MongoDB for MEAN Stack, mongoDB download and Install, #MongoDB ​ , #Angular ​ , #Nodejs ​ , Mongodb installation, Mongodb for Angular 11, mongodb for angular 10, mongodb for angular 9, mongodb with Testycodeiz, Mongodb for MEAN, Download MongoDB Link: mongodb.com/try/download/community?tck=docs_server