More on Components Flashcards

1
Q

There are two ways for setting/using an interface. What for and why?

A

One is just for data as data type.
export interface Product {…}
Second is like feature set (like implementing an interface in C# ) by defining methods and properties without any code, just structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

by Encapsulating styles in the component metadata

A

we won’t affect any other component in the application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What to do in order to implement custom pipe

A

Create a class with @Pipe decorator and implement PipeTransform interface.

Set logic in the transform method.

We need to add the custom pipe to the same angular module that would use this custom pipe. 
Add it to the declarations array. 

Also, we need to import the pipe stuff.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Getter and setter

A

Often define a private variable (_name) and is used only by the getter or setter.

The benefit is that we can write custom code that will execute on getting/setting value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

An arrow function is

A

compact syntax for defining a function.

Classic named function:
capitalizeName(product: IProduct) :string {
return product.ProductName.toUpperCase();
}

Arrow function:
(product: IProduct) => product.productName.toUpperCase();

Use arrow function any time you need to pass a function in to another function/method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly