Creating a new Angular project sets up all the files and tools you need to build a web app. It saves time and avoids mistakes by preparing everything automatically.
When you want to start building a new web app using Angular.
When you need a ready-made structure with best practices for your project.
When you want to use Angular's tools like live server and testing right away.
When you want to keep your code organized and easy to maintain.
When you want to quickly share your app with others or deploy it.
Syntax
Angular
ng new project-name
Replace project-name with your desired app name.
This command creates a folder with all setup files and installs dependencies.
Examples
This creates a new Angular project called my-first-app with default settings.
Angular
ng new my-first-app
This creates a new Angular project with routing enabled, so you can add multiple pages easily.
Angular
ng new my-app --routing
This sets up the project to use SCSS for styling instead of plain CSS.
Angular
ng new my-app --style=scss
Sample Program
This sequence creates a new Angular project named sample-app with routing and CSS styling. Then it moves into the project folder and starts the development server so you can see your app in the browser.
Angular
ng new sample-app --routing --style=css
cd sample-app
ng serve
OutputSuccess
Important Notes
Make sure you have Node.js and Angular CLI installed before running ng new.
You can add options like --routing or --style to customize your project setup.
After creating the project, use ng serve to start a local server and see your app live.
Summary
Use ng new project-name to create a new Angular app with all setup done for you.
You can customize the project with options like routing and style format.
Start the app with ng serve to view it in your browser.
Practice
(1/5)
1. What command do you use to create a new Angular project named my-app with default settings?
easy
A. ng generate project my-app
B. ng create my-app
C. angular new my-app
D. ng new my-app
Solution
Step 1: Understand Angular CLI command for new projects
The Angular CLI uses ng new followed by the project name to create a new project.
Step 2: Identify the correct syntax
The correct command is ng new my-app. Other options are invalid CLI commands.
Final Answer:
ng new my-app -> Option D
Quick Check:
Angular CLI new project = ng new [OK]
Hint: Use 'ng new' plus project name to create Angular app [OK]
Common Mistakes:
Using 'ng create' instead of 'ng new'
Typing 'angular new' which is not a CLI command
Using 'ng generate project' which is invalid
2. Which of the following commands correctly creates a new Angular project with routing enabled and SCSS as the style format?
easy
A. ng new my-app --routing --style=scss
B. ng new my-app -routing -style=scss
C. ng new my-app --routing scss
D. ng new my-app --route --style=scss
Solution
Step 1: Recall Angular CLI options for routing and style
The correct flags are --routing to enable routing and --style=scss to set SCSS styles.
Step 2: Check syntax correctness
ng new my-app --routing --style=scss uses correct double dashes and equals sign. Other options have wrong flags or missing dashes.
Final Answer:
ng new my-app --routing --style=scss -> Option A
Quick Check:
Enable routing and SCSS with --routing and --style=scss [OK]
Hint: Use double dashes and equals for options in ng new [OK]
Common Mistakes:
Using single dash for long options
Writing '--route' instead of '--routing'
Omitting equals sign for style option
3. After running ng new test-app --routing --style=css and then cd test-app followed by ng serve, what will happen?
medium
A. The app will fail to compile due to missing routing module
B. The Angular app will compile and be available at http://localhost:4200
C. The app will compile but show a blank page because CSS is not supported
D. The command will throw an error because 'ng serve' must be run before 'cd test-app'
Solution
Step 1: Understand Angular CLI workflow
Creating a project with routing and CSS style is valid. Changing directory into the project folder is required before serving.
Step 2: What ng serve does
ng serve compiles and launches a local server at port 4200 by default, showing the app in the browser.
Final Answer:
The Angular app will compile and be available at http://localhost:4200 -> Option B
Quick Check:
ng serve runs app at localhost:4200 [OK]
Hint: Run ng serve inside project folder to view app in browser [OK]
Common Mistakes:
Running ng serve outside project folder
Assuming CSS is unsupported
Expecting errors from valid routing option
4. You run ng new my-app --routing --style=less but get an error saying the style option is invalid. What is the likely cause?
medium
A. LESS is not supported by Angular CLI by default without extra setup
B. The --routing flag must come after --style option
C. You must use --styles instead of --style
D. The project name 'my-app' is invalid
Solution
Step 1: Check Angular CLI supported style formats
Angular CLI supports CSS, SCSS, Sass, and Stylus by default. LESS requires extra setup or dependencies.
Step 2: Analyze error cause
The error about invalid style option likely means LESS is not recognized without additional configuration.
Final Answer:
LESS is not supported by Angular CLI by default without extra setup -> Option A
Quick Check:
LESS needs extra setup, not default [OK]
Hint: Check if style format is supported by default before using [OK]
Common Mistakes:
Thinking option order matters
Using --styles instead of --style
Assuming project name causes style errors
5. You want to create a new Angular project named shop-app with routing enabled, SCSS styles, and skip installing npm packages initially. Which command should you use?
hard
A. ng new shop-app --routing --style=scss --skipNpm
B. ng new shop-app --routing --style=scss --no-install
C. ng new shop-app --routing --style=scss --skip-install
D. ng new shop-app --routing --style=scss --skip-npm
Solution
Step 1: Identify correct flags for skipping npm install
The Angular CLI uses --skip-install to skip installing npm packages after project creation.
Step 2: Confirm routing and style flags
--routing enables routing, and --style=scss sets SCSS styles correctly.
Final Answer:
ng new shop-app --routing --style=scss --skip-install -> Option C
Quick Check:
Use --skip-install to skip npm install [OK]
Hint: Use --skip-install to avoid automatic npm install [OK]
Common Mistakes:
Using incorrect flag names like --no-install
Trying camelCase flags like --skipNpm
Using hyphenated flags not recognized by CLI
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.