@@ -129,3 +129,76 @@ A: Provide it in the root module.
129129** Why do we need provider aliases? And how do you create one?**
130130
131131A: To substitute an alternative implementation for a provider. Can create like so: ` { provide: LoggerService, useClass: DateLoggerService } `
132+ 133+ 134+ ## Lifecycle Hooks Questions:
135+ 136+ ** What is the possible order of lifecycle hooks in Angular?**
137+ 138+ A: ngOnChanges, ngOnInit, ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAfterViewInit, ngAfterViewChecked, ngOnDestroy.
139+ 140+ ** When will ngOnInit be called?**
141+ 142+ A: Called once, after the first ngOnChanges.
143+ 144+ ** How would you make use of onNgInit()?**
145+ 146+ PA: fetch initial component data (e.g. from server).
147+ 148+ ** What would you consider a thing you should be careful doing on onNgInit()?**
149+ 150+ A: ??
151+ 152+ ** What is the difference between onNgInit() and constructor() of a component?**
153+ 154+ A: a directive’s data-bound input properties are not set until after construction, so that’s one difference.
155+ 156+ ## Pipes Questions:
157+ 158+ ** What is a pure pipe?**
159+ 160+ A: A pipe that is only executed when Angular detects a pure change to the input value (e.g. new primitive object or new object reference).
161+ 162+ ** What is an impure pipe?**
163+ 164+ A: A pipe that is executed during every component change detection cycle (i.e., often – every keystroke, mouse move).
165+ 166+ ** What is an async pipe?**
167+ 168+ A: an impure pipe that accepts a promise or observable as input and eventually returns emitted values.
169+ 170+ ** What kind of data can be used with async pipe?**
171+ 172+ A: stateful, asynchronous
173+ 174+ ** What types of pipes are supported in Angular 2?**
175+ 176+ A: Pure and impure pipes (async pipes a kind of impure pipe).
177+ 178+ ## Routing Questions:
179+ 180+ ** What is the difference between RouterModule.forRoot() vs RouterModule.forChild()? Why is it important?**
181+ 182+ A: forRoot is a convention for configuring app-wide Router service with routes, whereas forChild is for configuring the routes of lazy-loaded modules.
183+ 184+ ** How does loadChildren property work?**
185+ 186+ A: the Router calls it to dynamically load lazy loaded modules for particular routes.
187+ 188+ ** When does a lazy loaded module get loaded?**
189+ 190+ A: When its related route is first requested.
191+ 192+ ** How would you use a Route Guard?**
193+ 194+ A: You would implement CanActivate or CanDeactivate and specify that guard class in the route path you’re guarding.
195+ 196+ ** How would you intercept 404 errors in Angular 2?**
197+ 198+ A: Can provide a final wildcard path like so: { path: ‘** ’, component: PageNotFoundComponent }
199+ 200+ ** This link doesn't work. Why? How do I fix it?**
201+ ` <div routerLink='product.id'></div> `
202+ 203+ A: ` <a [routerLink]="[’product.id’]">{{product.id}}</a> `
204+
0 commit comments