📖 Scenario: You want to start a new web app using Angular. This app will show a simple welcome message on the page.
🎯 Goal: Create a new Angular project with a basic component that displays a welcome message.
📋 What You'll Learn
Create a new Angular standalone component called AppComponent.
Add a title variable with the value 'Welcome to Angular!'.
Use the @Component decorator with selector, template, and standalone: true.
Bootstrap the AppComponent in main.ts using bootstrapApplication.
💡 Why This Matters
🌍 Real World
Starting a new Angular project is the first step to building modern web apps with reusable components and reactive UI.
💼 Career
Knowing how to set up and bootstrap Angular projects is essential for frontend developer roles using Angular framework.
Progress0 / 4 steps
1
Create the AppComponent with a title variable
Create a standalone Angular component called AppComponent. Inside it, declare a public variable title and set it to 'Welcome to Angular!'.
Angular
Hint
Use @Component decorator with selector, template, and standalone: true. Declare title inside the class.
2
Add a template to display the title
Update the @Component decorator in AppComponent to include a template that shows the title variable inside an <h1> tag using Angular interpolation.
Angular
Hint
Use Angular interpolation {{ title }} inside the <h1> tag in the template property.
3
Set up main.ts to bootstrap AppComponent
In main.ts, import bootstrapApplication from @angular/platform-browser and AppComponent. Then call bootstrapApplication(AppComponent) to start the app.
Angular
Hint
Use bootstrapApplication(AppComponent) to launch the Angular app.
4
Complete the Angular project setup
Ensure AppComponent is exported from app.component.ts and main.ts bootstraps it. This completes the minimal Angular project setup.
Angular
Hint
Check that AppComponent is exported and bootstrapped correctly.
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.