Complete the code to declare a variable with a type in Angular using TypeScript.
let userName: [1] = 'Alice';
TypeScript uses types like string to specify the kind of data a variable holds. This helps Angular catch errors early.
Complete the code to define a function with typed parameters in Angular using TypeScript.
function greet(name: [1]): string { return `Hello, ${name}!`; }
number or boolean for text data.The parameter name should be a string because it represents text.
Fix the error in the Angular component class by adding the correct type annotation.
export class AppComponent { title: [1] = 'My App'; }
number or boolean instead of string.The title holds text, so it must be typed as string to avoid errors.
Complete the code to create a typed Angular service method that returns a number.
getCount(): [1] { return this.count; }
string as return type or missing semicolon.The method returns a number type and the statement ends with a semicolon ;.
Fill both blanks to define a typed Angular component property with an initial value.
export class UserComponent { userAge: [1] = [2]; }
string type or adding quotes around the number.The property userAge is a number type, initialized to 30. No extra character is needed after the number.