Analyze Folder setup in AngularProject (2024)

AngularJS vs Angular

AngularJS is based on the model view controller, whereas Angular6 is based on the components structure
that uses a TypeScript 2.9

Angular come up with Angular CLI which eases the installation.

Go to this site https://cli.angular.io to install Angular CLI. and find the all essential command.

to check wheher node.js and Npm has installed on your machine.

use below command

node -v — will displays a version of Node js if it is installed on your system

npm -v — will displays a version of Npm if it is installed on your system

////////////
use below command to install angular CLI

npm install -g @angular/cli //command to install Angular6

////////////
To create a new angular project

open IDE Visual studio Code and press – CTRL + ~ will open a command prompt window now use below command.

ng new AngulardemoApp // name of the project

this command will create a new project with all essenial folder and files in a complete package in a single go.

each folders and files that is created automatically will discuss in details later.

////////////
to builds the application and starts the web server.

ng serve

/////////////
to see the output of project.

Type the url http://localhost:4200/ in the browser and see the output.

here port 4200 is a default port

/////////
change the port

ng serve --host 0.0.0.0 -port 4205

////////

The Angular6 app folder has the following folder structure −

1-e2e − end to end test folder. Mainly e2e is used for integration testing and helps ensure the application works fine.2-node_modules − The npm package installed is node_modules. You can open the folder and see the packages available.3-src − This folder is where we will work on the project using Angular6.

/////// file structure
1-.angular-cli.json − It basically holds the project name, version of cli, etc.

2-.editorconfig − This is the config file for the editor..gitignore − A --gitignore file should be committed into the repository, in order to share the ignore rules with any other users that clone the repository.karma.conf.js − This is used for unit testing via the protractor. All the information required for the project is provided in karma.conf.js file.package.json − The package.json file tells which libraries will be installed into node_modules when you run npm install.

//////testing
protractor.conf.js − This is the testing configuration required for the application.

tsconfig.json − This basically contains the compiler options required during compilation.tslint.json − This is the config file with rules to be considered while compiling.

//////
The src folder is the main folder, which internally has a different file structure.

app.module.ts − If you open the file, you will see that the code has reference to different libraries,
which are imported. Angular-cli has used these default libraries for the import – angular/core, platform-browser. The names itself explain the usage of the libraries.

 They are imported and saved into variables such as declarations, imports, providers, and bootstrap. declarations − In declarations, the reference to the components is stored. The Appcomponent is the default component that is created whenever a new project is initiated. We will learn about creating new components in a different section. imports − This will have the modules imported as shown above. At present, BrowserModule is part of the imports which is imported from @angular/platform-browser. providers − This will have reference to the services created. The service will be discussed in a subsequent chapter. bootstrap − This has reference to the default component created, i.e., AppComponent.

AppComponent a component consist of below files

app.component.css − You can write your css structure over here. Right now, we have added the background color to the div as shown belowapp.component.html − The html code will be available in this file.app.component.spec.ts − These are automatically generated files which contain unit tests for source component.app.component.ts − The class for the component is defined over here. You can do the processing of the html structure in the .ts file. The processing will include activities such as connecting to the database, interacting with other components, routing, services, etc.

////////
Assets
You can save here project’s images, js files in this folder.

///////
Environment
This folder has the details for the production or the dev environment. The folder contains two files.
environment.prod.ts
environment.ts

//////////
favicon.ico
This is a file that is usually found in the root directory of a website.

//////////
index.html
This is the file which is displayed in the browser.

/////////
The body has . This is the selector which is used in app.component.ts file and will display the details from app.component.html file.

main.ts

platformBrowserDynamic().bootstrapModule(AppModule);
bootstrap: [AppComponent]

In app.component.ts, there is a selector: app-root which is used in the index.html file. This will display the contents present in app.component.html

///////
polyfill.ts
This is mainly used for backward compatibility.

///////
styles.css
This is the style file required for the project.

//////
test.ts
Here, the unit test cases for testing the project will be handled.

///
tsconfig.app.json
This is used during compilation, it has the config details that need to be used to run the application.

////////
tsconfig.spec.json
This helps maintain the details for testing.

////////
typings.d.ts
It is used to manage the TypeScript definition.

Analyze Folder setup in AngularProject (2024)

FAQs

What is the dist folder structure in Angular? ›

dist/ Folder The dist folder is the build folder which contains all the files and folders which can be hosted on the server. The dist folder contains the compiled code of your angular application in the format of JavaScript and also the required HTML and CSS files.

How to create a folder in Angular project? ›

By default, the CLI command ng new my-app creates a workspace folder named "my-app" and generates a new application skeleton in a src/ folder at the top level of the workspace. A newly generated application contains source files for a root module, with a root component and template.

What is the features folder in Angular? ›

Features folder

This folder contains the features of the application. Each feature has its own module that contains a collection of components, services, directives, pipelines, and other code that encapsulates a specific aspect of the application's functionality.

What is a good project folder structure? ›

The pyramid model is the best project management folder structure because it's easy to scale. For example, let's say MarCom decides to collaborate with another company for their event.

What is the best folder structure for TypeScript? ›

👍 Rules of thumbs:
  • Keep your code files in a seperate folder, away from configuration files.
  • Name your folders by their technical capabilities (Onion / Clean Architecture approach), avoid naming folders by features (Vertical Slice Architecture).
Jan 5, 2024

How to define a highly scalable folder structure for your Angular project? ›

Highly Scalable Angular Folder Structure
  1. Prerequisites. Before serving the project, you need to have Node version 8.9 and npm 5.5. ...
  2. Installing. You can install the projects dependencies by running. ...
  3. Json Server. We've used the JSON Server to create mock up a fake backend for this project. ...
  4. Development server. ...
  5. Scripts. ...
  6. License.

What is Node_modules folder in Angular? ›

In the context of Node. js, the node_modules folder is a directory that typically resides in the root of a Node. js project. It is used to store the dependencies (external libraries or packages) that your Node. js project relies on.

How do I create a project folder structure? ›

Best Practices for Folder Structure in Project Management
  1. Create a master folder. ...
  2. Use subfolders for each project phase. ...
  3. Add folders for documents and deliverables. ...
  4. Include a folder for meeting notes. ...
  5. Create a folder for your project schedule. ...
  6. Organize files by date, name, or type.
Feb 10, 2024

How to create the folder and components in Angular? ›

To create a new component manually:
  1. Navigate to your Angular project directory.
  2. Create a new file, <component-name>. ...
  3. At the top of the file, add the following import statement. ...
  4. After the import statement, add a @Component decorator. ...
  5. Choose a CSS selector for the component.

What is an Angular project structure? ›

Angular provides the Angular CLI (Command Line Interface) to generate a basic project structure. By running ng new followed by your project name, Angular CLI creates a new project with a default structure. However, as your project grows, you may need to adapt the structure to suit your specific requirements.

In which folder Angular is installed? ›

Understanding the folder structure
  1. node_modules - Installed dependencies from package.json.
  2. src - This is the main Source code folder. app - Contains all angular-related files. ...
  3. angular. json - CLI refers to angular. ...
  4. karma. conf. ...
  5. package. json - Packages dependency maintained here.
  6. tsconfig.
Jan 18, 2024

What is the difference between core and shared folder in Angular? ›

CoreModule should have only services and be imported only once in the AppModule . SharedModule should have anything but services and be imported in all modules that need the shared stuff (which could also be the AppModule ).

What is the root folder in Angular? ›

This folder contains your projects dependencies including Angular, autoprefixer, browserify, caniuse-lite, postcss and much more.

How to organize a large Angular project? ›

For larger applications, organizing code based on features or functionality is a recommended approach. Each feature has its own module containing related components, services, and routing configuration. This structure promotes separation of concerns and improves the overall project maintainability.

Which data structure is best for file directory? ›

So B+ tree is best for keeping track of directories and files in a computer.

What is the basic structure of Angular? ›

The basic building blocks of the Angular framework are Angular components. Components use services, which provide background functionality not directly related to views such as fetching data. Such services can be injected into components as dependencies, making your code modular, reusable, and efficient.

Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 6001

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.