You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,16 +4,6 @@ This is a collection of Angular 2 interview questions I've found online, along w
4
4
5
5
Note: "PA" === Possible Answer (one of many valid ones), and "A" === Answer.
6
6
7
-
## Animations Questions
8
-
9
-
**How do you define transition between two states?**
10
-
11
-
PA: Using the transition and animate function in an animations block like so: `animations: [transition('inactive => active'), animate('100 ms ease-in')]`
12
-
13
-
**How do you define a wildcare state?**
14
-
15
-
A: Using the asterisk - example: `transition('* => active'), animate('100ms ease-in'))`
16
-
17
7
## Template Syntax Questions
18
8
19
9
**What is a template reference variable, and how would you use it?**
@@ -24,6 +14,18 @@ A: A variable (defined using a #) in a component template, which can be referenc
24
14
25
15
A: Interpolation binding, one way binding, two way binding.
26
16
17
+
**What does the ngFor template syntax look like?**
18
+
19
+
A: example:`<ul><li *ngFor="let val of values">{{val}}</li></ul>`
20
+
21
+
**What does the pipe syntax look like in Angular templates?**
22
+
23
+
A: example: `<div>{{ value | my-pipe : option }}</div>`
24
+
25
+
**What does an interpolated string look like in a template?**
**What is the minimum definition of a component?**
@@ -54,6 +56,10 @@ A: Implement your own ErrorHandler and configure it in the list of providers for
54
56
55
57
PA: One way would be to use angular2-logger, which is a package inspired by log4j.
56
58
59
+
**How would you use the ngClass directive?**
60
+
61
+
A: For example: `<div [ngClass]="{firstCondition: 'class1', secondCondition: 'class2'}">...</div>`
62
+
57
63
**How do you resolve a template URL relative to a Component class?**
58
64
59
65
A: By specifying the moduleId to be module.id in the Component decorator. (Note: while this is still needed when using SystemJS, it is not necessary anymore when using Webpack module bundler for Angular 2 projects.)
@@ -205,6 +211,16 @@ A: Can provide a final wildcard path like so: { path: ‘**’, component: PageN
A: boolean or a Promise/Observable resolving to boolean value.
218
+
219
+
**What is <router-outlet> for?**
220
+
221
+
A: Place where routes are mounted in the app??
222
+
223
+
208
224
## Styling Questions:
209
225
210
226
**How would you select a custom component to style it?**
@@ -280,7 +296,41 @@ PA: Use formErrors
280
296
A: Verifying some field using some asynchronous call (perhaps a server call)... return a `Promise<ValidationResult>` from your validator. When creating a FormControl object, you can pass an asynchronous validator into the constructor (e.g. `new FormControl(‘value’, syncValidator, asyncValidator)`).
281
297
282
298
283
-
## Architecture Questions:
299
+
**What is patchValue used for?**
300
+
301
+
A: Setting a form value (one or more fields with an object) bypassing validation.
302
+
303
+
## Animations Questions
304
+
305
+
**How do you define transition between two states?**
306
+
307
+
PA: Using the transition and animate function in an animations block like so: `animations: [transition('inactive => active'), animate('100 ms ease-in')]`
308
+
309
+
**How do you define a wildcare state?**
310
+
311
+
A: Using the asterisk - example: `transition('* => active'), animate('100ms ease-in'))`
312
+
313
+
## Architecture / Framework Questions:
314
+
315
+
**What are some of the top level building blocks of the Angular framework?**
316
+
317
+
A: Services, Templates, Modules, Components, Providers, etc.
318
+
319
+
**What is AOT?**
320
+
321
+
A: Ahead of time compilation.
322
+
323
+
**What are some differences between Angular 2 and 4?**
324
+
325
+
A: Improvements in AOT; allowing else clause in ngIf, few other things...
326
+
327
+
**What are some security related features built in to the Angular framework?**
328
+
329
+
A: Sanitation, to prevent cross site scripting. Built-in support in the HttpClient to prevent cross-site request forgery.
330
+
331
+
**How can you bypass sanitation in Angular and why would you do so?**
332
+
333
+
A: To inject known safe code, you can bypass sanitation (e.g. to embed an iframe).
0 commit comments