#12 Create Component using Angular CLI | Angular Components & Directives | A Complete Angular Course

procademy
1 Jun 202318:49

Summary

TLDRThis lecture explains how to create Angular components manually and with Angular CLI. It starts by detailing the process of defining a component class, adding the view template and styles, and registering the component manually in the app module. The instructor then introduces the Angular CLI command 'ng generate component' to automate these tasks, showing how it speeds up development. The lecture also covers fixing a compilation error due to a missing Bootstrap reference and demonstrates the refactoring of HTML into child components, styling them, and verifying results in the browser.

Takeaways

  • 🔧 Manually creating components in Angular involves defining a class, decorating it with @Component, and registering it in the app.module.ts.
  • ⚙️ Using the Angular CLI simplifies component creation by automating the generation of the component class, view template, and registration in the main module.
  • 🛠️ The command 'ng generate component [component name]' automatically creates a new component with the required files and registers it in the app module.
  • 🗂️ Removing unnecessary dependencies (like Bootstrap) requires cleaning up references in the angular.json file to prevent compilation errors.
  • 🖥️ The CSS and HTML for a component are scoped to that component, meaning styles in one component won't affect another unless applied globally.
  • 🚀 Using Angular CLI for component generation speeds up the development process by automating tasks such as registering components.
  • 📁 Child components can be created inside parent component folders and referenced within the parent’s HTML for a cleaner structure.
  • 🔄 Refactoring large HTML sections into separate components makes code more modular and easier to manage, as shown with the top menu and main menu components.
  • 🎨 Styles for components can be moved from parent components to their respective child component CSS files for better encapsulation.
  • 📜 The Angular CLI ensures that any new components are automatically declared in the main module, reducing manual intervention.

Q & A

  • What is the purpose of the @Component decorator in Angular?

    -The @Component decorator is used to define an Angular component. It decorates a class by providing metadata about the component, such as the selector, template, and styles.

  • How do you manually create and register a component in Angular?

    -To manually create a component, you define a class decorated with the @Component decorator. Then, register the component by adding it to the 'declarations' array in the appmodule.ts file.

  • What is the Angular CLI command to generate a component?

    -The Angular CLI command to generate a component is 'ng generate component <component-name>'. This can also be shortened to 'ng g c <component-name>'.

  • What tasks are automated by using the Angular CLI to generate a component?

    -When using Angular CLI, it automates the creation of the component class, view template, stylesheet, and also registers the component in the app module. This eliminates the need for manual registration.

  • How do you fix the error caused by uninstalling Bootstrap in an Angular project?

    -The error occurs because the Angular.json file is still referring to the Bootstrap CSS file. To fix this, you need to remove the reference to 'bootstrap.min.css' from the 'styles' array in the Angular.json file.

  • What happens if you try to use a component selector without importing its CSS styles?

    -If you use a component selector without importing its specific CSS styles, the HTML will be rendered but without any styles being applied. This is because Angular's CSS is scoped to each component, and styles are not applied globally unless specified.

  • How can global styles be applied to all anchor elements in an Angular project?

    -To apply global styles to all anchor elements, you should add the necessary styles for the 'a' tag inside the 'styles.css' file. This will apply the styles globally across all components.

  • Why would you refactor the HTML inside a component?

    -Refactoring the HTML in a component helps to organize the code better. For example, separating different sections like 'top menu' and 'main menu' into their own components improves maintainability and clarity.

  • How do you handle the CSS styles for child components in Angular?

    -In Angular, CSS styles are scoped to individual components. If a child component requires specific styles, you need to move those styles from the parent component's CSS to the child component's CSS file.

  • Why don't you need to manually declare a component when using Angular CLI to create it?

    -When using Angular CLI, it automatically declares the component in the 'declarations' array of the app module. This is one of the conveniences of using CLI, as it speeds up development by handling this task for you.

Outlines

00:00

🛠️ Introduction to Angular Components

The paragraph provides a review of creating Angular components manually, explaining how to define view templates, style the view, and register the component within the app module using the `@Component` decorator. It then introduces Angular CLI as a more efficient alternative for generating components. Using the `ng generate component` command, Angular CLI automates the creation of the component class, view template, style sheet, and registration in the app module, eliminating the need for manual setup.

05:00

🚀 Fixing Bootstrap Errors and Using Angular CLI

The speaker addresses an error in the project caused by an uninstalled Bootstrap reference in the `angular.json` file, explaining how to remove the unused path. After correcting this, the `ng serve` command is run to verify that the project compiles successfully. Following this, a new component named 'top header' is created using the Angular CLI (`ng generate component top-header`). The resulting component files are then reviewed and the `app-top-header` selector is adjusted to `top-header`. HTML and CSS styles are added to the component, demonstrating how Angular CLI automatically registers components in the app module.

10:02

📋 Creating and Styling the Top Menu Component

The focus shifts to creating a 'top menu' component, using the `ng generate component top-menu` command. After the component is generated, the default test file is deleted. HTML and CSS content for the top menu is then extracted from the header component and added to the top menu's template and stylesheet files. The speaker highlights that styles defined in one component’s CSS file are not applied to child components, demonstrating this with a missing CSS issue. The styles are then successfully transferred and applied in the appropriate component files, resulting in a correctly rendered top menu.

15:03

⚙️ Creating the Main Menu Component and Removing the Search Bar

The paragraph explains how to create a 'main menu' component in a similar manner as the top menu, using the Angular CLI. HTML content for the main menu is extracted from the header component and added to the main menu’s template. The associated CSS is also moved to the new component’s CSS file. The speaker points out a slight alignment issue and resolves it by making additional CSS adjustments. Additionally, an unnecessary search bar is removed from the header component and its styles are cleaned up. The speaker concludes by noting that the newly created components are automatically registered in the app module by Angular CLI.

Mindmap

Keywords

💡Component

A component in Angular is a self-contained unit that controls a part of the user interface. It consists of a TypeScript class, an HTML view template, and a CSS stylesheet. In the video, components such as the 'header component' and 'top header component' are discussed as essential building blocks for organizing and structuring the app's UI.

💡Angular CLI

Angular CLI (Command Line Interface) is a tool that helps developers automate the creation of Angular components, services, and modules. The video demonstrates how Angular CLI simplifies the development process by automating tasks like generating component files and registering them in the app module using commands like 'ng generate component'.

💡Decorator

A decorator in Angular is a special syntax used to add metadata to a class, making it an Angular component. In the video, the '@Component' decorator is used to define components like 'header component' and 'top header component'. This metadata includes information such as the template and styles associated with the component.

💡Template

A template in Angular refers to the HTML structure that defines the view for a component. The video explains how each component, such as 'top header component', has its own HTML template that defines what will be rendered on the web page. The template connects the view with the component’s logic and styling.

💡AppModule

AppModule is the root module in an Angular application, where all components, services, and other modules are declared. The video highlights how manually created components must be registered in the 'AppModule' file, but Angular CLI automates this process when creating components.

💡ng generate

'ng generate' is an Angular CLI command that automatically generates files for components, services, or other features of an Angular app. In the video, this command is used to create components like 'top header' and 'main menu', simplifying the development workflow by generating the necessary files and configurations.

💡CSS Styles

CSS styles are used to define the visual appearance of an Angular component. In the video, CSS is applied to components such as 'top header' and 'top menu' to enhance their presentation. The script also covers how styles are component-scoped, meaning each component’s styles are encapsulated and don’t affect other components.

💡Child Component

A child component is a component that is nested inside a parent component. In the video, the 'top menu' and 'main menu' components are described as child components of the 'header component', demonstrating how Angular’s component-based architecture allows complex UIs to be broken down into smaller, reusable pieces.

💡Selector

A selector in Angular is a custom HTML tag that represents a component in the application’s DOM. In the video, the selectors 'app-header' and 'app-top-header' are used to embed the header and top header components into other templates. The selector connects the component logic to its place in the overall app structure.

💡Module Declarations

Module declarations in Angular refer to the list of components, directives, and pipes that are part of an Angular module. In the video, the 'declarations' array in 'app.module.ts' is where components like 'header' and 'top header' are declared. The video emphasizes that when using Angular CLI, the process of adding components to this array is automated.

Highlights

Learned how to create and style components in Angular manually and using Angular CLI.

Explained the process of creating a component class decorated with @Component and how to register it in app.module.ts.

Introduced the Angular CLI command 'ng generate component' to automate component creation.

Demonstrated how Angular CLI generates a component class, view template, and stylesheet automatically.

Resolved an Angular compilation error caused by an incorrect reference to the Bootstrap file in angular.json.

Showed how to use Angular CLI to create a top-header component and adjust its selector and template.

Explained the automatic registration of a component in the declarations array of app.module.ts using Angular CLI.

Described the process of refactoring HTML by separating top navbar and main navbar into separate components.

Discussed how to organize child components by creating top menu and main menu components inside the header component.

Showed how to move the top menu's HTML and CSS from the header component to its respective component files.

Highlighted that Angular component CSS styles are scoped to the component and do not apply to child components.

Explained the need to copy relevant CSS styles to a component's specific CSS file for them to apply.

Demonstrated global CSS by moving anchor styles from the component-specific CSS file to the global style.css.

Explained the process of cleaning up unused HTML and CSS for better maintainability.

Reiterated the benefits of using Angular CLI for speeding up development by automating component registration and setup.

Transcripts

play00:00

in the last few lectures we learned

play00:02

about component in great detail we

play00:04

learned how to create a component how to

play00:06

define the view template for that

play00:08

component and how to style that view

play00:10

template

play00:12

so if I go to the source folder inside

play00:14

this Source folder we have this app

play00:16

folder and in there we created this

play00:19

header component so if I go to this

play00:21

header component.ts file there we have

play00:23

this header component class decorated

play00:25

with at component decorator

play00:27

now we created this header component

play00:29

manually by defining this header

play00:31

component class decorating it with at

play00:33

component decorator and then registering

play00:35

this header component in the

play00:37

appmodule.ts file basically inside this

play00:40

declarations array so here you can see

play00:42

we are registering we are declaring this

play00:44

header component which we created

play00:47

now we can also create a component using

play00:50

angular CLI

play00:51

and for that we simply need to run this

play00:54

command

play00:55

so the command is NG generate component

play00:58

and the component name

play01:00

now what this command will do is it will

play01:03

first create a component class decorated

play01:05

with at component decorator

play01:07

it will also generate the view template

play01:09

and style sheet for that component

play01:11

and it will also register that component

play01:14

class in the main module so we don't

play01:16

have to do anything manually here in

play01:19

order to create a component

play01:20

everything will be taken care by angular

play01:23

CLI

play01:24

so let's see how we can create a

play01:25

component using this angular CLI command

play01:27

but before that let's first go ahead and

play01:30

let's fix the error which we introduced

play01:31

in our last lecture

play01:33

so in the last lecture from this angular

play01:36

application we uninstalled bootstrap

play01:38

right and when we uninstalled bootstrap

play01:41

we are still referring to that bootstrap

play01:44

file in our angular.json file basically

play01:47

here inside this Styles array so you see

play01:49

we are still referring to that

play01:51

bootstrap.min.css file inside this

play01:54

angular.json

play01:55

and because of this what is happening is

play01:57

when I am trying to compile this project

play01:59

I am getting this error so the error

play02:02

says can't resolve this file path

play02:05

in this project and because of that the

play02:08

compilation is failing

play02:10

so in order to fix this problem all we

play02:12

have to do is we have to go back to vs

play02:14

code and from the angular.json file from

play02:16

within this Styles array we need to

play02:18

remove that path we need to remove that

play02:21

reference

play02:22

and with this if I save the changes now

play02:25

our angular application should compile

play02:27

properly without any errors so if I go

play02:29

back to command prompt

play02:31

here let's first go ahead and let's stop

play02:33

this process by pressing Ctrl C

play02:37

let me clear the command prompt here and

play02:40

then let's again go ahead and let's run

play02:42

this NG serve command

play02:44

and now we should not have any

play02:45

compilation errors

play02:49

so now you can see the project is

play02:51

compiling successfully and we don't have

play02:53

any compilation errors

play02:55

all right now let's go back and let's go

play02:57

ahead and let's create a new component

play02:59

using angular CLI for that

play03:01

let's open this terminal

play03:04

and what we want is we want to create a

play03:07

new component called top header

play03:10

so let me first clear the terminal here

play03:12

and in order to create this top header

play03:14

component we are going to use angular

play03:16

CLI so here we need to type the command

play03:18

NG generate

play03:21

insert we can also write it as ngg

play03:24

and we want to generate a component so

play03:26

we need to specify that

play03:29

or in short we can also write it as C

play03:32

for component and then the name for the

play03:34

component so I'm going to call this

play03:36

component top header

play03:39

let's press enter and what this command

play03:41

will do is it will create a folder with

play03:43

the name top header and inside that it

play03:45

will generate all the component related

play03:47

files

play03:48

so now if I go to Source folder

play03:52

in the source folder if I go to app

play03:53

folder there you will see inside this

play03:56

app folder we have another folder called

play03:58

top header and inside this top header

play04:01

folder we will have all the files

play04:03

related to the top header component

play04:05

so here we have the top header

play04:07

component.ts file there we have this top

play04:10

header component class decorated with

play04:11

ADD component decorator

play04:13

in there we have the selector called as

play04:15

app top header but instead of calling it

play04:18

app top header I will simply call it top

play04:20

header

play04:21

okay and wherever we will use this top

play04:24

header selector there this HTML file

play04:27

will be rendered so this is the view

play04:28

template for this top header component

play04:31

so let's go to this top header

play04:33

component.html file in there currently

play04:36

we simply have one paragraph element so

play04:38

wherever we will use this top header

play04:41

selector there that paragraph will be

play04:43

rendered okay

play04:45

and we also have top header

play04:47

component.css file inside this we can

play04:49

write some CSS for our top header

play04:52

component

play04:53

then we also have this top header

play04:55

component dot spec.ts file basically it

play04:58

is a file inside which we can write some

play05:00

unit tests for our component but for now

play05:02

I don't want to worry about writing unit

play05:04

tests so what I will do is I will simply

play05:07

go ahead and I will delete this file

play05:14

okay now let's go ahead and let's use

play05:17

this top header component in our app

play05:18

component so I'll copy this selector

play05:21

let's go to app component.html and there

play05:24

before this app header

play05:26

let's use this top header

play05:31

okay so for this top header

play05:35

this paragraph will be rendered let's

play05:37

see that in web page so let's go back to

play05:39

the web page

play05:41

and there you will notice that paragraph

play05:43

has been rendered

play05:45

but instead of rendering a paragraph

play05:47

here I want to display a top header now

play05:50

in order to save some time

play05:52

I have already written some HTML for the

play05:54

top header so I'll copy that HTML from

play05:57

here

play05:58

let's go back to vs code and here

play06:01

instead of that paragraph let's paste

play06:03

that HTML

play06:04

here I don't need this ID for now so

play06:07

I'll remove it

play06:08

so this is a very simple HTML where we

play06:10

have a div with this class ecard top

play06:12

header in there we have a paragraph with

play06:15

this value and then we are also

play06:18

displaying a font awesome icon

play06:21

so let me save these changes here let's

play06:23

go back to the web page

play06:26

and there you will see that paragraph

play06:30

okay

play06:32

now in order to style this top header

play06:34

again I have written some CSS so let's

play06:37

grab that CSS from here

play06:40

let's go back to vs code

play06:42

and let's go to

play06:43

top header component.css and there let's

play06:47

paste that CSS let's save the changes

play06:50

again

play06:51

let's go back to the web page

play06:54

and this is how our top header looks

play06:56

like

play06:57

okay

play07:00

now you might ask okay using the angular

play07:03

CLI we created the component but when we

play07:06

created the component manually that time

play07:08

we also had to register it in the main

play07:11

module in the app module class

play07:14

right but we have not done that for this

play07:16

top header component well that's because

play07:19

after creating this top header folder

play07:22

and generating the files for the top

play07:24

header component angular CLI will also

play07:26

declare that component in the main

play07:28

module so if I go to this app module.ts

play07:31

file there you will see that this top

play07:34

header component that has already been

play07:36

declared inside this declarations array

play07:38

so it has been imported from this file

play07:41

path and then it has been added to this

play07:44

declarations array we don't have to do

play07:46

it manually

play07:47

so all these manual tasks are taken away

play07:49

from us when we create a component using

play07:52

angular CLI

play07:53

and this helps us in speeding up the

play07:56

development process and that's the

play07:58

advantage of using angular CLI for

play08:00

creating the angular component

play08:03

all right

play08:04

let me go ahead and let me close these

play08:06

files now

play08:11

okay

play08:13

now what I also want is if I go to this

play08:15

header component and if I go to this

play08:17

header component HTML file you will see

play08:19

that here in this header component we

play08:21

have lot of HTML so what I want is I

play08:24

want to refactor this HTML

play08:27

if I go to the web page

play08:28

there you will see we have two navbars

play08:31

so the first one let's say is top navba

play08:34

and this one is the main navba so what I

play08:37

want is I want to create separate

play08:39

components for this top nav bar or maybe

play08:42

we can call it top menu and also the

play08:44

main menu

play08:46

so let's go ahead and let's create

play08:47

components for these two menus

play08:51

now let me go ahead and let me clear the

play08:53

terminal first

play08:55

so the top menu and the main menu these

play08:59

two components are going to be the child

play09:00

component of this header component

play09:03

because we are going to use those

play09:05

components inside this header component

play09:08

okay so since these components are going

play09:10

to be the child component of this header

play09:12

component what we need to do is

play09:14

we need to move inside this header

play09:16

component first for that we can type the

play09:19

CD command So currently we are in the

play09:22

project directory basically this

play09:24

directory from here we need to go to

play09:26

Source folder from The Source folder we

play09:28

need to go to app folder and from the

play09:30

app folder we need to go to header

play09:32

folder so we can say

play09:34

Source slash app slash header

play09:39

if I press enter

play09:41

now we are in the header folder and

play09:44

inside that header folder we want to

play09:45

create a new component for that again we

play09:47

can use NG generate command in short you

play09:50

can also write it as ngg and we want to

play09:53

generate a component

play09:55

and I'm going to call this component

play09:58

top menu

play10:01

let's press enter

play10:03

and now this command should generate the

play10:06

top menu component with all the required

play10:08

files

play10:09

so it has been generated and in the

play10:11

header folder you will see a new folder

play10:13

called top menu has been created and in

play10:16

there we have all the component related

play10:18

files again let me go ahead and let me

play10:19

delete this spec.ts file we don't need

play10:22

it for now

play10:25

okay so if I go to topmanycomponent.ts

play10:28

file there we have this top menu

play10:30

component class decorated with at

play10:32

component decorator and there the

play10:34

selector is app top menu again I'll

play10:36

simply call it as

play10:37

top menu

play10:39

for that the view template is this HTML

play10:42

file and style sheet is this HTML file

play10:46

so inside this I want to write the HTML

play10:49

for top menu basically the HTML for

play10:53

this menu

play10:54

so I'll copy it from header

play10:56

component.html

play10:58

so this is the top menu let me cut it

play11:02

from here

play11:03

and I will specify a comment here

play11:08

top menu so that letter I will add that

play11:12

top menu component selector after this

play11:15

comment

play11:16

so let me go to

play11:18

topmanycomponent.html instead of this

play11:20

paragraph

play11:21

let me paste that HTML here

play11:24

and then we also want to design this

play11:27

HTML

play11:28

and we have the CSS for this HTML file

play11:32

inside header component.css file

play11:36

so here if I scroll up we have the CSS

play11:39

for that class ecard top bar now if I

play11:43

don't copy this CSS class from here and

play11:45

paste it inside

play11:47

topmanycomponent.css this style will not

play11:49

get applied on that div so in the top

play11:51

menu component.html we have this div

play11:54

with this ecard topper class name

play11:57

okay but in the CSS file we don't have

play12:00

any style for that class but we have

play12:03

some Styles defined for that CSS class

play12:06

in header component dot CSS file

play12:09

but we have learned that this CSS it

play12:12

will be only applied to the view

play12:14

template of header component it will not

play12:17

get applied to the view template of any

play12:19

other component and just to prove that

play12:21

let me go ahead and let me copy the top

play12:25

menu selector from here

play12:27

and

play12:29

let's use it in the header

play12:30

component.html so here let's go ahead

play12:33

and let's use it

play12:35

okay let's save the changes

play12:38

let's go back to the web page

play12:41

and there you will see that the top menu

play12:43

is being displayed but there is no CSS

play12:46

style applied on that

play12:47

and this is what we learned earlier

play12:50

so even though there is a CSS style

play12:52

defined for that CSS class in the header

play12:55

component.css file it will not get

play12:57

applied on that because that is a

play13:00

completely different component this top

play13:02

menu component it is a different

play13:04

component than header component even

play13:06

though it is a child component of this

play13:07

header component this CSS style is not

play13:10

getting applied there

play13:12

so what I will do is I will cut it from

play13:14

here

play13:15

let's go to top menu component.css file

play13:18

and there let's paste that CSS

play13:21

save the changes let's go back to the

play13:24

web page

play13:25

and now you will see that some Styles

play13:27

have been applied here so basically now

play13:28

it is displayed in the right hand side

play13:31

but again the underlines for these links

play13:34

are still there and the color of these

play13:36

links are still blue

play13:37

that's because we also need to take

play13:41

these Styles which we have defined for

play13:43

the anchor element basically this style

play13:47

and we need to put it inside the top

play13:49

menu component.css file but instead of

play13:52

specifying this style here

play13:54

so I can specify it here and I can save

play13:57

it and if you go to the web page again

play14:00

there those styles are there but then

play14:03

for these anchor elements those styles

play14:05

are gone

play14:06

so what we want is we want to apply

play14:08

these tiles for all the anchor elements

play14:11

we want to specify these Styles globally

play14:13

for all the anchor elements so what I

play14:16

will do is I will take this style for

play14:19

this anchor element from here

play14:21

and I will add that CSS style in the

play14:23

style.css file so that it will be

play14:26

applied globally

play14:27

so now on all the anchor elements in

play14:30

this angular project these Styles will

play14:33

be applied so if I save the changes now

play14:35

and if we go back

play14:37

now those styles are applied on these

play14:39

menu items also these links also and

play14:42

these links also

play14:44

okay so in this way we separated the top

play14:47

menu component from the header component

play14:50

so if I go back

play14:52

let me close this topmany component.css

play14:55

file let's also close this style.css

play14:57

file

play14:58

and let me close this top many

play15:00

component.html file we are not going to

play15:02

do anything in this file right now

play15:05

and if I go to this header

play15:06

component.html file now it is a bit

play15:08

leaner so now to display the top menu we

play15:11

only have one line of HTML

play15:13

in the same way I also want to separate

play15:16

this main menu into a separate component

play15:18

so again let me go ahead and let me

play15:20

clear the terminal here and again we

play15:23

want to create this new component inside

play15:25

the header component only because this

play15:27

main menu component it is also going to

play15:29

be a child of header component

play15:32

so again I will say NG generate

play15:34

component and I'm going to call this

play15:36

component main menu

play15:41

let's press enter

play15:43

so again it should generate all the

play15:45

required files for the main menu

play15:46

component all right it has been

play15:48

generated a folder has been created here

play15:50

called main menu

play15:51

from here let me first go ahead and let

play15:53

me delete this spec.ts file

play15:59

if I go to main menu component.ts there

play16:02

you will see we have this main menu

play16:03

component class

play16:05

decorated with a component decorator it

play16:07

has this selector template URL and style

play16:10

urls so now let's go to header

play16:12

component.html and let's cut this HTML

play16:16

from here

play16:17

and here we want to display main menu

play16:21

okay

play16:22

now let's go to main menu component.html

play16:25

instead of this paragraph let's paste

play16:27

that HTML so here we have a div with

play16:30

this class ecart menu so let's go ahead

play16:33

and let's copy the CSS for this class

play16:35

from header component dot CSS

play16:39

so somewhere we should have the main

play16:42

menu okay this ecart menu let's cut it

play16:45

from here

play16:48

let's go to main menu component.css file

play16:51

in there let's paste it

play16:54

let's see if the changes let's go to

play16:57

main menu component.ts file from there

play17:00

let's get the selector again instead of

play17:01

calling it app main menu I'll simply

play17:03

call it main menu

play17:05

I'll copy this selector

play17:08

and again let's go to

play17:10

headercomponent.html and after this

play17:12

comment

play17:13

let's use that selector

play17:17

okay with this let's save the changes

play17:19

let's go back to our application

play17:22

and you can see that main menu

play17:25

all right it looks great but for some

play17:27

reason it has shifted a bit left but

play17:30

that's okay for now

play17:31

let's go back to vs code again let's go

play17:34

to headercomponent.html and from here I

play17:37

also want to remove this search bar so

play17:39

so

play17:40

in the web page

play17:42

we also have this search bar I don't

play17:44

want it in the header

play17:46

so I'll simply go ahead and I will

play17:48

remove it from here

play17:51

okay and from the header component.css

play17:54

let's also go ahead and let's remove the

play17:58

CSS for that search bar so we want to

play18:01

remove this ecart search bar

play18:04

record search box

play18:07

and ecard search button

play18:10

let's go to the web page

play18:12

and that search bar has been removed

play18:15

all right so this is all from this

play18:17

lecture in this lecture we learned how

play18:19

we can create an angular component using

play18:21

angular CLI and also if I go back you

play18:24

will notice that these two components

play18:25

which we have just created this main

play18:27

menu and top menu if I go to

play18:29

appmodule.ts file there you will notice

play18:32

that those classes are automatically

play18:35

declared here inside this declarations

play18:36

array

play18:38

okay so when we use angular CLI we don't

play18:40

have to do these things manually angular

play18:43

CLI will take care of that

Rate This

5.0 / 5 (0 votes)

関連タグ
AngularCLIComponent CreationWeb DevelopmentFrontendTypeScriptHTMLCSSModuleBest Practices
英語で要約が必要ですか?