Importance: [⭐⭐⭐⭐] Similar to showing quantifiable achievements when starting your resume, you’ll want to give examples with results that can be measured and which are relevant. When given the opportunity, explain to them how their current requirements would be handled expertly should you be given the role: “From the job description, I understand you are looking for someone who can take your outreach team to the next level. During my time with ABC, I performed a similar task, with excellent results…”
Importance: [⭐⭐⭐] If you feel that the interviewer is spending too much time concerned with some old position, explain to them how it helped get you to where you are today, and how it would help you in the future. Frame these as learning experiences that remain useful to you.
Importance: [⭐⭐⭐] Savvy interviewers may ask you, “what was the worst part about your last job?” This is because the reply you give here will answer a slew of other unasked questions about your personality, behavior, loyalty, and more. Don’t speak ill about your former company or coworkers, at least not in a direct way. Interviewers get turned off when you opt for the low road. Keep your wits about you as you answer this loaded question, and tiptoe around saying the very worst: Or, wrap a criticism in a blanket of compliment:
Importance: [⭐⭐⭐] Just because you’re in the hot seat doesn’t mean you can’t guide the course of the interview. Steer the conversation from your end, especially when confronted with a question or course of discussion that could paint you in a less-than-perfect light. For example: Interviewer: “Can you tell me how your ABC project turned out?” Interviewee: Crap. That one didn’t end well. Attempting to divert. “I more-recently completed project XYZ, completely similar to ABC and with results I’m proud of. May I tell you about that?” See that? You know your project XYZ had great results, so you are trying to chat about that one, instead. Also, leaving the ball in their court at the end with the question keeps them feeling like they remain in control of the interview.
Importance: [⭐⭐] Unlike the strengths question, the employer here wants to see how you answer more than what you answer. Use answers that show that you’re self-aware and open to improvement. Read some great responses to this question here: "What Is Your Greatest Weakness?" Best Answers
When working with objects in Angular templates, you encounter situations where variables are declared without default values – the variable is just presented as a type definition. When trying to access a property on the variable that isn’t readily available, Angular will throw an error saying the variable is undefined. For example, your template looks like this, you’re reading the name property of a student object:
<p>{{ student.name }}</p>
And this was how the variable was declared in the component file:
interface Student {
name: String;
age: Number:
}
@Component({
selector: 'app-component',
})
export class AppComponent{
student: Student;
}
Angular will throw an error here. Using the safe navigation operator, we can safeguard the name property against any null and undefined values. The safe navigation operator in Angular is this syntax ?., and we can update the template to use this:
<p> {{ student?.name }} </p>
When you run this, Angular doesn’t throw any errors and your console is clear. Another useful technique of avoiding this error is using the and (&&) operator to check if the value exists before reading the property path. We can update the example to use this syntax:
<p> {{ student && student.name }} </p>
If the value doesn’t exist, Angular will avoid evaluating the expression and nothing is rendered between the tags.
This very useful feature is supported out of the box in Angular. I’m sure you’ve encountered instances where imports in your applications are just messy and difficult to read. You have something like:
import { ThatComponent } from '../../../components/this-component/child-component'
import { ThisService } from '../../../../services/this-service'
I’m sure it would be more helpful to have aliases for the components and services paths – this would make these imports relatively easy to read and import. When working with React, I’ve researched how to achieve this, but most solutions involve ejecting your application, which doesn’t really sound pleasing. Well, to achieve this in your Angular application, all you need to do is to update the tsconfig.json file:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@components": "app/components",
"@services": "app/services",
},
"..."
}
}
What happened here is that the default value of the baseUrl property ./ was updated to point to the src directory. Then we added a new property called paths, which is an object containing key values pairs representing aliases defined for paths in our application. Aliases were defined for the components folder and the services folder. Now if we want to attempt the imports in the previous example, we’ll do this:
import { ThatComponent } from '@components/this-component/child-component';
import { ThisService } from '@services/this-service';
This is way cleaner and easier to read than the previous example. If you’ve not booted up your editor to do this for your application already, then you should get to it.
From Angular version 6 onward, you can develop custom native elements that can be used outside Angular. This can be done using a package introduced by Angular called Angular Elements (@angular/elements). This package provides a way to createCustomElements and polyfills to support browsers that aren’t compatible with web components. With this package, you can package your favourite components and use them within other frameworks like React, Vue, etc. To get started building custom native elements in Angular, install the Angular Elements package in your application using the following command:
ng add @angular/elements --name=<your_project_name>
You can follow the quick tutorial in the official Angular documentation to get started.
This utility, introduced in Angular version 6, can be used to add a published package to your work environment, and it’ll run schematics in the background to update the functionality of your application. When downloading a package using this command, it also installs extra dependencies it needs to run, like polyfills, etc. Your application can be converted to a progressive web application using service workers and providing offline functionality using the command. You can implement progressive web application features in your application by running the following command:
ng add @angular/pwa
Or if you wish to add a touch of Material Design in your application, you can add the Angular Material library
ng add @angular/material
When building your application, it is always useful to reduce side effects like HTTP requests, time-based events, etc. Abstracting these from the component to services will help reduce the complexity of the component and also ensures the reusability of the service. An example would be fetching data from an external server. You could fetch data within your component like this:
import { Component } from "@angular/core";
@Component({
selector: 'app-component',
template: '<ul> <li *ngFor="let item of items">{{item}}</li> </ul>',
})
export class AppComponent implements OnInit{
constructor(private http: HttpClient){
}
items = [];
getItems(){
return this.http.get('http://server.com/items')
}
ngOnInit(){
this.getItems.subscribe(items => this.items = items);
}
}
This method used in fetching the items is local to the component and can’t be reused, and if items are being fetched in other components, this whole procedure will be repeated and that’s not very DRY. If multiple network requests are made, the component will be littered with these methods. Let’s refactor this component to use a service for external requests.
@Injectable({
providedIn: 'root'
})
export class ItemService {
constructor (private http: HttpClient) {}
getItems() {
return this.http.get('http://server.com/items');
}
}
Then we’ll make use of it in the component:
import { Component } from "@angular/core";
@Component({
selector: 'app-component',
template: '<ul> <li *ngFor="let item of items">{{item}}</li> </ul>',
})
export class AppComponent implements OnInit{
constructor(private itemsService: ItemsService){
}
items = [];
ngOnInit(){
this.itemsServices.getItems().subscribe(items => this.items = items);
}
}
This service can be used to fetch items application-wide.