Angular Web Framework Angular Industry Standards 2 — Questions and Answers
Question 1: Which Angular style guide convention is recommended for naming a service that handles user data?
- UserData
- userDataService
- UserDataService (Correct answer)
- user-data.service
Correct answer: UserDataService
The Angular style guide recommends PascalCase for class names, so UserDataService is correct for the class itself.
Question 2: According to Angular's official style guide, what is the recommended maximum number of lines for a single component file?
- 200
- 400 (Correct answer)
- 100
- 500
Correct answer: 400
The Angular style guide recommends keeping files under 400 lines to maintain readability and single responsibility.
Question 3: What is the recommended approach for handling HTTP errors in enterprise Angular applications?
- Catch errors in every component separately
- Use a global HTTP interceptor (Correct answer)
- Use try/catch in every service method
- Ignore errors and let Angular handle them
Correct answer: Use a global HTTP interceptor
A global HTTP interceptor centralizes error handling, logging, and retry logic across the entire application.
Question 4: Which testing ratio is recommended by the Angular team for a balanced test suite?
- 10% unit, 70% integration, 20% e2e
- 70% unit, 20% integration, 10% e2e (Correct answer)
- 50% unit, 30% integration, 20% e2e
- 33% each
Correct answer: 70% unit, 20% integration, 10% e2e
Angular follows the testing pyramid: mostly unit tests, fewer integration tests, and minimal e2e tests for the best cost-to-coverage ratio.
Question 5: What is the industry-standard tool used for enforcing Angular coding standards in CI pipelines?
- Angular Compiler
- TSLint (deprecated) replaced by ESLint with @angular-eslint (Correct answer)
- Prettier alone
- ngBuild --lint
Correct answer: TSLint (deprecated) replaced by ESLint with @angular-eslint
TSLint is deprecated; the Angular community standard is ESLint configured with the @angular-eslint ruleset.
Question 6: What does the Angular CLI schematic `ng generate` enforce by default to ensure consistency?
- Barrel imports
- Consistent file naming and folder structure per Angular style guide (Correct answer)
- Strict mode TypeScript
- Component-only architecture
Correct answer: Consistent file naming and folder structure per Angular style guide
ng generate schematics follow the Angular style guide naming conventions (kebab-case files, PascalCase classes) by default.
Question 7: Which practice is considered a standard for managing environment-specific configuration in Angular?
- Hardcoding values in components
- Using environment.ts and environment.prod.ts with file replacements (Correct answer)
- Storing config in cookies
- Reading config from window.location
Correct answer: Using environment.ts and environment.prod.ts with file replacements
Angular's environment file replacement mechanism at build time is the standard way to manage environment-specific values.
Which Angular style guide convention is recommended for naming a service that handles user data?