#04 Angular files and folder structure| Getting Started with Angular | A Complete Angular Course

procademy
25 May 202319:38

Summary

TLDRThis lecture offers an insightful overview of Angular project structure, focusing on the files and folders generated by Angular CLI. It explains the purpose of each, including the 'node_modules' for third-party libraries, 'package.json' for project configurations and dependencies, and the crucial 'angular.json' for project-wide settings. The video also delves into the 'src' folder, highlighting its role in housing application source code and differentiating between global and component-specific CSS styles. The session aims to familiarize developers with essential Angular components, setting a foundation for deeper exploration in subsequent lectures.

Takeaways

  • 📁 The 'node_modules' folder stores all third-party libraries that the Angular application depends on and is not deployed in production or checked into the repo.
  • đŸ› ïž Developers can reinstall dependencies by running 'npm install' after checking out the project code, which is not including the 'node_modules' folder.
  • 📝 The 'package.json' file contains project configurations and lists of dependencies and devDependencies that the Angular project relies on.
  • 🔍 The 'package-lock.json' file ensures consistent installation of dependencies across different environments by recording their exact versions.
  • đŸ‘„ The '.editorconfig' file sets coding standards for a team, helping to maintain consistency across multiple developers' contributions.
  • đŸš« The '.gitignore' file specifies which files and folders to exclude from the git repository, such as 'node_modules' and other non-essential files.
  • đŸ› ïž The 'angular.json' file is crucial for Angular project configuration, detailing project settings, styles, scripts, and the main entry point.
  • 📖 The 'tsconfig.json' file includes settings for the TypeScript compiler, which compiles TypeScript code into JavaScript for browser execution.
  • đŸ—ïž The 'src' folder is the central location for all application source code, including components, services, and modules.
  • 📾 The 'assets' folder holds static assets like images and icons, which are publicly accessible when referenced in the application.
  • 🌐 The 'index.html' file is the main HTML rendered in the browser, with dependencies injected during the build process by Angular CLI.

Q & A

  • What is the purpose of the 'node_modules' folder in an Angular project?

    -The 'node_modules' folder is used to store all the third-party libraries that the Angular application might depend on. These libraries are downloaded from npm and are essential for the development of the application. However, this folder is not deployed to the production server nor checked into the version control system like git.

  • Why is the 'node_modules' folder not included when pushing to a git repository?

    -The 'node_modules' folder is not included in the git repository because it is purely for development purposes. It can be regenerated by running 'npm install' whenever needed, which makes it unnecessary to keep in version control.

  • How does an Angular application function without the 'node_modules' folder?

    -If the 'node_modules' folder is missing, such as after checking out code from a repository, the developer can run 'npm install' to download and install all the necessary packages that the Angular project depends on, thus regenerating the 'node_modules' folder.

  • What role does the 'package.json' file play in an Angular project?

    -The 'package.json' file is a standard configuration file for Node projects, including Angular. It contains project-related configurations, such as the project's name and version, as well as scripts for starting and building the project. Importantly, it lists the dependencies and devDependencies that the project relies on.

  • How does 'npm install' know which packages to install for an Angular project?

    -The 'npm install' command looks inside the 'package.json' file to determine the dependencies and devDependencies that need to be installed. It then downloads and installs these packages into the 'node_modules' folder.

  • What is the purpose of the '.editorconfig' file in a development team environment?

    -The '.editorconfig' file is used to define and maintain consistent coding styles between different editors and IDEs used by developers in a team. It helps to avoid errors and maintain a consistent code style across the project.

  • What does the '.gitignore' file specify?

    -The '.gitignore' file specifies which files and folders should be excluded from the git repository. This is useful for not tracking files that are not needed in version control, such as the 'node_modules' folder or temporary files.

  • What is the significance of the 'angular.json' file in an Angular project?

    -The 'angular.json' file contains all the configurations related to the Angular project, such as project name, type, styles, scripts, and the main entry point. It is the most important configuration file for an Angular application.

  • What is the 'package-lock.json' file and why is it important?

    -The 'package-lock.json' file records the exact version of every installed dependency, including their sub-dependencies. It ensures that the same versions of dependencies are installed consistently across different environments, which is crucial for avoiding inconsistencies in development, production, and other environments.

  • What is the role of the 'tsconfig.json' file in an Angular project?

    -The 'tsconfig.json' file contains settings for the TypeScript compiler. The compiler uses these settings to compile TypeScript code into JavaScript that browsers can understand. It's an important configuration for managing how the code is transpiled.

  • What is the 'src' folder in an Angular project and why is it important?

    -The 'src' folder is where all the application's source code is stored. It contains components, services, modules, and other essential parts of the application. Developers spend most of their time in this folder, creating and managing the application's functionality.

  • What is the purpose of the 'assets' folder in an Angular project?

    -The 'assets' folder is used to store static assets such as images, icons, and text files. These assets are made public and can be accessed directly from the browser, making it the place to keep all publicly accessible resources.

  • Why is the 'index.html' file in the 'src' folder important for an Angular application?

    -The 'index.html' file is the main HTML file that gets rendered in the browser when the Angular application runs. It is where the application is bootstrapped, and all dependencies are injected during the build process by the Angular CLI.

  • What is the 'main.ts' file and its significance in starting an Angular application?

    -The 'main.ts' file is the starting point of an Angular application. It is where the app module is bootstrapped, and the application's execution begins. It is similar to a main method in other programming languages, marking the entry point of the application.

  • What is the difference between global CSS styles and component-specific CSS styles in an Angular project?

    -Global CSS styles are defined in the 'style.css' file and are applied to the entire application, affecting all components and directives. In contrast, component-specific CSS styles are defined in a component's own CSS file (e.g., 'app.component.css') and only affect the HTML elements of that particular component.

Outlines

00:00

📁 Understanding Angular Project Structure

The lecture provides an introductory overview of the file and folder structure generated by Angular CLI when creating a new project. It explains the purpose of each file and folder, starting with the 'node_modules' folder, which stores third-party libraries. The importance of not deploying 'node_modules' in production and not including it in the version control system is emphasized. The explanation includes how to reinstall dependencies using 'npm install' after deleting the 'node_modules' folder and the role of 'package.json' in managing project configurations and dependencies.

05:02

📝 Navigating Angular Configuration Files

This paragraph delves into the significance of 'package.json', detailing how it lists project configurations, scripts for project operations like 'ng serve' and 'ng build', and the dependencies and devDependencies sections that Angular projects rely on. It also touches on the '.editorconfig' file for team environment setup, ensuring consistent coding standards, and the '.gitignore' file for specifying files and folders to exclude from version control. The paragraph further explains how 'npm install' uses 'package.json' to identify and install the necessary packages.

10:03

đŸ› ïž Angular's Core Configuration and Source Files

The script continues with an exploration of the 'angular.json' file, highlighting its role as the central configuration file for the Angular project, including project details and build configurations. It also mentions 'package-lock.json', which ensures consistent installation of dependencies across different environments. The 'README.md' file is briefly acknowledged, followed by an explanation of 'tsconfig.json', the TypeScript compiler settings file. The focus then shifts to the 'src' folder, emphasizing its importance as the repository for all application source code, including components, services, and modules, and the default files and folders it contains.

15:04

🌐 Public Assets and Angular Application Entry Points

The final paragraph discusses the 'assets' folder, where static assets like images and icons are stored and made publicly accessible. It demonstrates how to access these assets via the browser and the importance of placing them within the 'assets' folder for public access. The paragraph also covers the 'web-icon.ico', the main entry point 'index.html', and the 'main.ts' file, which serves as the starting point for the Angular application. Additionally, it explains the role of 'style.css' for global CSS styles and component-specific styles in 'component.css' files.

Mindmap

Keywords

💡Angular

Angular is a platform and framework for building client-side applications using HTML, TypeScript, and other technologies. It is maintained by Google and is known for its robustness and scalability. In the video, Angular is the main subject, as the script discusses the structure and components of an Angular project, which is essential for understanding how to build and organize Angular applications.

💡Angular CLI

Angular CLI is a command-line interface tool that is used to initialize, develop, scaffold, and maintain Angular applications. It automates many aspects of development, such as creating new components or services. In the script, the CLI is mentioned as the tool used to generate the initial project structure and files, emphasizing its importance in streamlining the setup process for Angular projects.

💡Node Modules

The 'node_modules' folder is a directory in an Angular project where all third-party libraries and dependencies are stored. These libraries are typically installed via npm (Node Package Manager). The script explains that while this folder is crucial for development, it is not deployed to production servers and is excluded from version control repositories, such as Git.

💡npm install

The 'npm install' command is used to install all the dependencies listed in a project's 'package.json' file. This command is vital for setting up a new Angular project or after deleting the 'node_modules' folder, as it restores all necessary packages. The script illustrates this by showing how the command is used to reinstall dependencies after manually deleting the 'node_modules' folder.

💡package.json

The 'package.json' file is a manifest that includes important metadata about the project, such as its name and version. More importantly, it lists the project's dependencies and devDependencies, which are third-party libraries that the project relies on. The script discusses how 'npm install' reads this file to determine which packages to install, highlighting its role in managing project dependencies.

💡Dependencies

Dependencies in the context of an Angular project refer to the third-party packages that the application directly relies on to function. The script explains that these are listed in the 'dependencies' section of the 'package.json' file and are installed by 'npm install', ensuring that the project has all the necessary libraries to run.

💡Dev Dependencies

Dev Dependencies are packages that are used during the development process of an Angular project but are not required for the application to run in production. These are listed separately in the 'package.json' file and are used for tasks such as testing or building the project. The script clarifies the distinction between dependencies and devDependencies.

💡Source Folder

The 'src' folder is the directory in an Angular project where all the application's source code resides. It contains components, services, modules, and other essential parts of the application. The script emphasizes the importance of the 'src' folder as the primary location for developers to write and organize their Angular code.

💡Components

In Angular, a component is a fundamental building block of the application's UI. It consists of a TypeScript class, an HTML template, and optionally a CSS stylesheet. The script mentions components in the context of the 'app' folder, where the default app component is created, and explains that every Angular application must have at least one component.

💡Modules

An Angular module is a container for providing and organizing code into functional units of an application. Each module can have its own components, directives, and services. The script refers to modules when discussing the 'app.module.ts' file, which is the main module file for the default application in an Angular project.

💡Assets

The 'assets' folder in an Angular project is used to store static assets such as images, icons, and text files. These assets are made publicly accessible and can be referenced in the application's code. The script demonstrates how assets are served from this folder and how they can be organized into subfolders for better management.

💡index.html

The 'index.html' file is the main entry point for an Angular application. It is the HTML file that gets rendered in the browser when the application runs. The script explains that this file does not contain direct references to stylesheets or JavaScript files, as these are injected during the build process by the Angular CLI.

💡main.ts

The 'main.ts' file is the starting point of an Angular application. It is where the application's root module is bootstrapped, effectively starting the application. The script describes this file as analogous to a 'main' method in other programming languages, signifying its role in initiating the application's execution.

💡TypeScript

TypeScript is a superset of JavaScript that adds static types and other features to the language. Angular applications are written in TypeScript, which is then compiled to JavaScript that browsers can execute. The script mentions TypeScript in the context of the 'tsconfig.json' file, which contains settings for the TypeScript compiler.

💡Global CSS

Global CSS styles are styles that apply across the entire Angular application, regardless of the component. The script discusses 'style.css' as the place to define these global styles, as opposed to component-specific styles that would be placed in individual component CSS files.

Highlights

Angular CLI generates a set of files and folders required for a new Angular project.

Node modules folder stores third-party libraries used by the application and is not deployed in production.

The 'npm install' command is used to install dependencies after checking out code from a repository.

Package.json file contains project configurations and lists of dependencies and devDependencies.

Angular applications depend on the exact versions of installed dependencies recorded in package-lock.json.

The 'ng serve' and 'ng build' commands are used to start and build Angular projects, respectively.

EditorConfig file defines coding standards for a team environment to maintain consistency in code.

Gitignore file specifies which files and folders to exclude from the Git repository.

Angular.json file is crucial for project configuration, including styles, scripts, and the main entry point.

The Source folder contains all the application's source code, including components, services, and modules.

App folder within Source is used for creating components, services, and modules specific to the application.

Assets folder holds static assets like images and icons, which are publicly accessible.

Index.html is the main HTML file rendered in the browser when the Angular app runs.

Main.ts is the entry point of the Angular application, responsible for bootstrapping the AppModule.

Style.css contains global CSS styles applied to all components and directives in the application.

Each component has its own CSS file for styles specific to that component.

Angular has removed unnecessary files and folders in version 16, streamlining the project structure.

Transcripts

play00:00

in this lecture we are going to have a

play00:02

quick overview of angular files and the

play00:05

folders which gets generated when we

play00:07

first create the angular project and we

play00:09

are going to understand the use of each

play00:11

of them one by one in brief so whenever

play00:14

we create a new angular project using

play00:16

angular CLI it generates a bunch of

play00:18

files and folders inside the project

play00:20

directory as you can see this angular

play00:23

ecart is our project directory and in

play00:25

this project directory there are a bunch

play00:27

of folders and files that have been

play00:29

generated automatically when we used

play00:31

angular CLI to create a new angular

play00:33

project and we created this new angular

play00:36

project using NG new command so when we

play00:39

use NG new command using angular CLI it

play00:42

creates a new project it generates a

play00:45

bunch of files and folders which is

play00:47

required for that project

play00:49

and each file and folder has its own

play00:51

purpose so let's see the use of some of

play00:53

the important files and folders of

play00:55

angular project which you should know

play00:56

about and let's start with this node

play00:59

modules folder so this folder is where

play01:02

all the third party libraries get stored

play01:05

on which our application might depend on

play01:07

so when we work on our angular project

play01:10

we might need to use some third-party

play01:12

libraries and we might need to download

play01:14

those third-party libraries from npm

play01:17

so whenever we will download those

play01:19

third-party libraries from npm those

play01:21

libraries will get stored inside this

play01:23

node modules folder now this folder it

play01:26

is purely full development purpose and

play01:28

we don't deploy this folder in

play01:30

production server

play01:31

also we don't check in this node modules

play01:34

folder in our repo so let's say you're

play01:37

using git as your code repo and you want

play01:39

to share this project code with your

play01:41

team members so what you will do is you

play01:43

will push these files and folders in the

play01:45

git repo and when you are going to push

play01:48

these files and folders to the git repo

play01:50

at that time you will not push this node

play01:52

modules folder as I said it is purely

play01:55

for the development purpose now you

play01:58

might say Manoj you said that in this

play02:00

node modules folder all the dependent

play02:02

libraries and packages will be stored so

play02:05

if we don't push this node modules

play02:07

folder in the code repo or while

play02:09

deploying it in the production then how

play02:11

the angular application will work

play02:13

because the angular application is

play02:15

dependent on those third-party libraries

play02:17

so how will this angular application

play02:19

work

play02:20

well what happens is so for example let

play02:22

me go ahead and let me delete this node

play02:24

modules folder

play02:27

so now that node modules folder has been

play02:29

deleted

play02:30

now let's just assume that we have just

play02:33

checked out this project code from the

play02:35

git repo or any other repo so let's say

play02:37

my teammate has checked in this project

play02:39

code in the git repo or any other repo

play02:42

and I have just checked out this code

play02:44

from that repo and in there I don't have

play02:47

the node modules folder in that case

play02:49

this angular application is not going to

play02:51

work because it is dependent on some

play02:54

packages and since the node modules

play02:56

folder is not there that means those

play02:57

dependent packages are not available

play02:59

this project is not going to work

play03:01

so what do we do now well all we have to

play03:05

do now is we can open Terminal here

play03:09

okay or you can also use command prompt

play03:11

let me clear the terminal here

play03:14

and currently I am in the project folder

play03:16

you see this is my project folder path

play03:19

and in the project folder path I just

play03:22

need to type an npm command npm

play03:26

install

play03:28

and then it is going to install all the

play03:31

dependent packages on which this angular

play03:33

project is dependent on

play03:35

and it is again going to create that

play03:37

node modules folder and in that node

play03:40

modules folder we will have all our

play03:42

dependent packages so if I go ahead and

play03:45

if I press enter it is going to create

play03:47

the node modules folder again and in

play03:50

that node modules folder we will have

play03:51

all our dependent packages

play03:54

so you see this node modules folder has

play03:56

been created and all the dependent

play03:58

packages and libraries are being

play04:00

downloaded and installed

play04:02

all right so all the packages have been

play04:04

installed again we have this node

play04:05

modules folder and in there we will have

play04:08

all our dependent packages

play04:10

okay

play04:12

now you might ask all right so we run

play04:15

this NTM install command and it

play04:17

installed all the dependent packages for

play04:19

this angular project but how does it

play04:22

know on which packages this angular

play04:24

project is dependent on

play04:27

that sphere this package.json file comes

play04:30

into picture

play04:31

so let's talk about this package.json

play04:33

file now

play04:35

this package.json file it is one

play04:37

important file and this is a standard

play04:40

configuration file which every node

play04:42

project has now this is an angular

play04:44

project but here we are going to install

play04:47

packages from npm right so every project

play04:51

which depends on npm will have this

play04:53

package.json file

play04:55

and in this package.json file you will

play04:58

have some project related configurations

play05:00

for example you can see the name of the

play05:02

project the version of the project

play05:03

currently it is set to 0.0.0 we can

play05:06

change this version then you can see the

play05:09

scripts which can be used in our angular

play05:11

project for example in order to start

play05:14

this angular project we use this NG

play05:16

serve command in order to build this

play05:18

angular project we can use this NG build

play05:20

command okay and we have all other

play05:22

Scripts then here we have two sections

play05:26

dependencies and Dev dependencies and

play05:30

these two sections stores all the third

play05:32

party dependencies which this angular

play05:34

project has

play05:36

so for example this angular project is

play05:38

dependent on these packages this at

play05:41

angular slash animation at angular slash

play05:43

common at angular slash Co let me

play05:46

actually show you that we are using this

play05:47

at angle slash Co in our project so

play05:50

again if I go to tack component

play05:52

if I open this app component.ts file you

play05:55

see here we are importing component from

play05:58

this angular slash Co package

play06:01

okay so this angular project is

play06:03

dependent on this package

play06:05

so this package.json file it has all

play06:08

those informations

play06:10

okay and we also have some Dev

play06:12

dependencies basically the difference

play06:14

between dependencies and Dev

play06:16

dependencies is that in the dependencies

play06:18

you will have the list of all those

play06:20

packages on which your project is

play06:22

directly dependent on

play06:24

but in the dev dependencies you will

play06:26

have the list of all those packages on

play06:28

which this angular project is dependent

play06:31

on while we are developing this angular

play06:32

project so these are all development

play06:35

dependencies these are the tools which

play06:37

we might need when we are developing our

play06:39

angular application

play06:41

okay so here you can see the list of all

play06:44

the third party packages all the third

play06:46

party libraries on which our project is

play06:48

dependent on so when we type let me

play06:51

clear the terminal again

play06:53

when we type this npm install command it

play06:57

is going to look inside this

play06:59

package.json file it will check for all

play07:02

the dependencies and all the dev

play07:03

dependencies and it is going to download

play07:06

and install all those third-party

play07:08

packages

play07:10

okay

play07:11

so this is how npm install knows which

play07:14

packages to install and store inside

play07:17

this node modules folder

play07:19

all right

play07:21

then we have this Source folder we will

play07:23

talk about it later let's go to this

play07:25

editor config file here

play07:27

so this file here it is basically used

play07:30

to set up the team environment

play07:32

so in a real project many developers may

play07:35

work on a single project and each

play07:37

developer may follow different coding

play07:39

standards to declare variables classes

play07:41

style size of each character length Etc

play07:45

but in the end we need to merge the code

play07:48

of each developer to produce the final

play07:50

product right

play07:52

and at that time it may produce some

play07:54

error or messy code AS each developer is

play07:57

having different coding standards

play07:59

now in order to solve this problem this

play08:01

edit config file is used where the

play08:04

standard rules are defined which needs

play08:06

to be followed by the developers in the

play08:08

teamwork

play08:09

and moreover the developers do not have

play08:11

access to this file and only the manager

play08:13

or the team lead who defines the rules

play08:15

can only have access to this file

play08:17

and in this file you can see all those

play08:19

rules you can Define your own rules for

play08:22

the coding standard as well now while

play08:24

developing the angular application we as

play08:26

a developer do not have to worry about

play08:28

this edit a config file it is the

play08:30

responsibility of the manager or the

play08:32

team lead who will Define these coding

play08:33

rules

play08:35

okay let's close this file as well and

play08:37

then we have this git igno file so let's

play08:40

say your team is using git as the code

play08:43

repo now when you are checking in your

play08:46

code to the git repo you might not want

play08:48

to check in all the files and folders in

play08:50

the git repo right so in this file you

play08:53

can specify the files and folders which

play08:55

you want to exclude from your git

play08:57

Repository

play08:58

if you have these folders in your

play09:00

angular project while checking in in the

play09:02

git repo so these folders will be

play09:04

ignored then you can see we are also

play09:06

ignoring this node modules folder as I

play09:09

mentioned we are not going to check in

play09:10

the node modules folder in the repo

play09:13

then if you have these files in your

play09:15

project these will also get ignored

play09:17

and you can specify all the folders and

play09:19

files which you want to ignore which you

play09:21

don't want to check into git repo so

play09:24

let's say in my angular project I have

play09:26

created a new folder

play09:30

I will call it maybe temp

play09:33

and in this step folder I am going to

play09:36

keep all the files which is not required

play09:38

for checking in for example in this temp

play09:40

file I am going to keep some notes or

play09:42

maybe the design document or something

play09:44

like that

play09:45

so I don't need to check in those files

play09:48

in the git repo so I want to ignore this

play09:51

file to be checked in into the git repo

play09:53

for that I can simply go ahead and I can

play09:56

include that folder here

play09:58

so I can say slash

play10:00

temp so this folder will be ignored and

play10:03

all the files which we have inside this

play10:04

folder that will also get ignored it

play10:07

will not get checked in in the git repo

play10:09

okay I hope it's clear let me go ahead

play10:12

and let me delete this folder

play10:15

then we have this angular.json file now

play10:19

this angular.json file it is one of the

play10:21

most important files and it contains all

play10:23

the configuration of your angular

play10:25

project

play10:26

so here you can see the project related

play10:29

configuration the project name is

play10:31

angular cart project type it is an

play10:33

application then we have all other

play10:35

configurations for example

play10:37

what are the style sheets we are going

play10:39

to use and where to find it so we are

play10:41

going to find the style.css in the

play10:43

source folder then what are the scripts

play10:45

we want to use we can specify it here

play10:48

inside this array

play10:49

here you can also see which file should

play10:52

be loaded when the angular runs for the

play10:54

first time in this case it is index.html

play10:56

file which is present in the source

play10:57

folder

play10:58

what is the main entry point for the

play11:00

angular application

play11:01

in this case it is main.ts so all these

play11:04

angular related configuration you will

play11:06

find inside this angular.json file now

play11:09

we are going to talk more about this

play11:11

angular.json file in our next lecture

play11:13

for now this should be it just keep in

play11:15

mind that this angular.json file is the

play11:17

most important file here and it contains

play11:19

all the configuration related to our

play11:21

angular project

play11:22

now we already talked about this

play11:24

package.json file we also have something

play11:25

called as packagelog.json

play11:28

now this package log.json file it

play11:31

records the exact version of every

play11:33

install dependency including its sub

play11:36

dependencies and their versions

play11:38

the purpose of package.log Json is that

play11:41

it ensures that the same dependencies

play11:43

are installed consistently across every

play11:46

different environment for example we

play11:48

might be deploying our angular

play11:49

application in development environment

play11:50

production environment integration

play11:52

environment so in all these environments

play11:55

the same version of all the dependencies

play11:57

gets installed this job is taken care by

play12:00

this package log.json file

play12:03

then we have this readme file we don't

play12:05

need to worry about this file

play12:07

let's close this one

play12:09

then another important file which we

play12:11

have is this tsconfig.json file this

play12:14

file it basically contains a bunch of

play12:16

settings for your typescript compiler

play12:18

and typescript compiler look at these

play12:21

settings and based on these settings it

play12:23

is going to compile your typescript code

play12:25

into JavaScript that the browsers can

play12:27

understand

play12:28

but for most of the part we don't have

play12:29

to worry about this ts.config file okay

play12:32

let's close this one

play12:34

let's also close this kit ignore

play12:36

and now let's talk about this Source

play12:38

folder so this Source folder is the most

play12:42

important folder and you as a developer

play12:44

will be spending a lot of time inside

play12:45

the source folder

play12:47

it is this Source folder in which we put

play12:50

all our application source code so every

play12:53

component service class modules

play12:55

everything we need in order to create an

play12:58

angular application that goes inside

play13:00

this Source folder now whenever we

play13:02

create an angular project by default

play13:04

angular framework creates a lot of files

play13:06

and folders within this Source folder

play13:08

and you can see those folders and files

play13:10

here

play13:11

so first of all we have this app folder

play13:14

this is the application folder whenever

play13:16

you want to create any component service

play13:19

or module you need to create it within

play13:22

this app folder

play13:23

okay so just remember that in an angular

play13:26

project we can have multiple

play13:28

applications

play13:29

and by default we get one application

play13:31

and that application is available inside

play13:33

this app folder

play13:35

and inside this app folder by default we

play13:38

have one app component so these four

play13:41

files together they create a component

play13:43

and we are calling it as app component

play13:46

and then we also have this app module.ts

play13:50

file so again remember that every

play13:53

application which we create in an

play13:54

angular project every application will

play13:56

have at least one module file okay so

play14:00

every angular application must have at

play14:02

least one component and one module in

play14:05

this case for this application we have

play14:07

one component so these four files

play14:09

together will create one component and

play14:11

we have one module

play14:13

now we're going to talk about modules

play14:16

and components in great detail in our

play14:18

coming lectures so we will not worry

play14:19

about that right now I will close this

play14:22

app folder

play14:23

then we have this assets folder now in

play14:27

this assets folder we store all our

play14:29

static assets for example images icons

play14:32

text files Etc

play14:34

and whatever we store inside this assets

play14:37

folder that will be public and that can

play14:39

be accessed for example let me go ahead

play14:42

and let me add an image inside this

play14:44

assets folder for that let me go to this

play14:48

folder here I have this sample files

play14:50

folder and in there I have an image I'll

play14:52

just drag this image and open vs code

play14:55

and I will put this image inside this

play14:57

assets folder okay so here we have this

play15:00

planet.jpg file now let's try to access

play15:03

this file from the browser let me go to

play15:06

the browser and there let's type root

play15:09

URL which is this localhost colon 4200

play15:12

then we have the assets folder and in

play15:15

there we have Planet dot jpg if I press

play15:19

enter you see that image has been

play15:22

rendered here

play15:23

so whatever file and folder you will

play15:25

place inside this assets folder that

play15:27

will be publicly accessible you can even

play15:30

put it inside a folder so inside this

play15:32

assets folder let me go ahead and let me

play15:33

create a new folder I will call it

play15:35

images

play15:36

and in that images let me go ahead and

play15:38

let me put this planet.jpg

play15:42

okay so now if I go to the browser I

play15:44

will have to specify that path so in the

play15:46

assets folder

play15:48

we have

play15:49

images folder and in that images folder

play15:52

we have planet.jpg and it is still

play15:55

accessible

play15:56

but if I go ahead and if I cut this

play15:59

planet.jpg from here

play16:01

so let me just cut it from here and let

play16:04

me put it in some other folder

play16:06

maybe let me put it inside this app

play16:08

folder itself

play16:12

and now if I go to the browser and if I

play16:14

try to access this planet.jpg from that

play16:16

app folder so if I say

play16:19

app slash planet.jpg if I press enter

play16:23

you see nothing is rendered here

play16:26

so only those files and folders which

play16:28

you put inside this assets folder only

play16:32

that will be accessible publicly

play16:34

so let me go ahead and let me move it

play16:36

again inside this images folder

play16:39

all right so in this assets folder we

play16:41

keep all our public assets like icons

play16:43

images text files Etc

play16:46

then we have this web icon dot Ico

play16:49

this is just a simple icon file which

play16:51

will get displayed in the browser so if

play16:53

I go to the browser

play16:55

here you will see that Fab icon has been

play16:57

rendered okay so based on your project

play17:00

icon you can just replace this five icon

play17:03

Ico with your application Fab icon

play17:07

then we have this index.html file this

play17:10

index.html file is the main HTML file

play17:12

which gets rendered in the browser when

play17:14

angular app runs and here in this

play17:16

index.html file you will see that we

play17:18

don't have any references to any style

play17:20

sheets or JavaScript files this is

play17:22

because all the dependencies will be

play17:24

injected to this index.html file during

play17:26

the build process by angular CLI and we

play17:29

will talk about it more in our coming

play17:31

lectures

play17:32

then we have this main.ts file so this

play17:36

main.ts is the typescript file and this

play17:38

file is basically the starting point of

play17:40

angular application

play17:41

so in a lot of programming languages we

play17:44

have this concept of main method which

play17:45

is the starting point of the application

play17:47

we have the same concept in angular also

play17:50

in this main.ts file all we are doing is

play17:53

we are bootstrapping this app module so

play17:57

when we will run this angular

play17:58

application it is going to execute this

play18:00

main.ts file first and there it will

play18:04

load this app module and everything else

play18:06

will start from there and again we are

play18:09

going to talk more about it in our next

play18:11

lecture

play18:12

then we have this style.css file this is

play18:15

where we add all the global CSS styles

play18:17

for our angular application

play18:19

so whatever CSS style we will specify

play18:21

here that will be applied to each

play18:23

component and each directive

play18:26

but for each component also we have a

play18:29

CSS file we call it component.css and in

play18:32

that component CSS file whatever style

play18:34

we will specify that will only get

play18:37

applied to that particular component for

play18:39

example in this case if I write some CSS

play18:42

style inside this appcomponent.css those

play18:45

CSS Styles will only get applied on the

play18:48

HTML elements of app component.html

play18:51

but whatever style we specify inside the

play18:53

style.css that will be applied globally

play18:57

all right so these were some important

play18:59

files and folders which we need to know

play19:01

about when we are working with angular

play19:03

project

play19:06

in the older versions of angular you

play19:07

will find more files and folders but

play19:10

they have been removed from angular 16.

play19:12

so we need not to worry about them

play19:14

and here we have briefly talked about

play19:16

each of these files and folders but as

play19:19

we move along in this course you will

play19:20

learn more about these files and folders

play19:22

and the need of each of them

play19:26

all right so this is all from this

play19:27

lecture if you have any questions then

play19:29

feel free to ask it thank you for

play19:31

listening and have a great day

Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Étiquettes Connexes
AngularProject StructureFile OverviewDevelopmentNode ModulesPackage.jsonTypeScriptWeb DevelopmentAngular CLInpm install
Besoin d'un résumé en anglais ?