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
Copy file name to clipboardExpand all lines: README.md
+18-19Lines changed: 18 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -914,19 +914,19 @@ You can download the PDF and Epub version of this repository from the latest run
914
914
915
915
31. ### What is a custom pipe?
916
916
Apart from built-in pipes, you can write your own custom pipe with the below key characteristics:
917
-
1. A pipe is a class decorated with pipe metadata **@Pipe** decorator, which you import from the core Angular library
917
+
1. A pipe is a class decorated with pipe metadata `@Pipe` decorator, which you import from the core Angular library
918
918
For example,
919
919
```javascript
920
920
@Pipe({name: 'myCustomPipe'})
921
921
```
922
922
2. The pipe class implements the **PipeTransform** interface's transform method that accepts an input value followed by optional parameters and returns the transformed value.
923
-
The structure of pipeTransform would be as below,
923
+
The structure of `PipeTransform` would be as below,
924
924
```javascript
925
925
interface PipeTransform {
926
926
transform(value: any, ...args: any[]): any
927
927
}
928
928
```
929
-
3. The @Pipe decorator allows you to define the pipe name that you'll use within template expressions. It must be a valid JavaScript identifier.
929
+
3. The `@Pipe` decorator allows you to define the pipe name that you'll use within template expressions. It must be a valid JavaScript identifier.
@@ -961,10 +961,9 @@ You can download the PDF and Epub version of this repository from the latest run
961
961
**[⬆ Back to Top](#table-of-contents)**
962
962
963
963
34. ### What is a bootstrapping module?
964
-
Every application has at least one Angular module, the root module that you bootstrap to launch the application is called as bootstrapping module. It is commonly known as AppModule. The default structure of AppModule generated by AngularCLI would be as follows,
965
-
966
-
```javascript
967
-
/* JavaScript imports */
964
+
Every application has at least one Angular module, the root module that you bootstrap to launch the application is called as bootstrapping module. It is commonly known as `AppModule`. The default structure of `AppModule` generated by AngularCLI would be as follows:
965
+
966
+
```javascript
968
967
import { BrowserModule } from '@angular/platform-browser';
969
968
import { NgModule } from '@angular/core';
970
969
import { FormsModule } from '@angular/forms';
@@ -986,7 +985,7 @@ You can download the PDF and Epub version of this repository from the latest run
986
985
bootstrap: [AppComponent]
987
986
})
988
987
export class AppModule { }
989
-
```
988
+
```
990
989
991
990
**[⬆ Back to Top](#table-of-contents)**
992
991
@@ -996,7 +995,7 @@ You can download the PDF and Epub version of this repository from the latest run
996
995
**[⬆ Back to Top](#table-of-contents)**
997
996
998
997
36. ### What is HttpClient and its benefits?
999
-
Most of the Front-end applications communicate with backend services over HTTP protocol using either XMLHttpRequest interface or the fetch() API. Angular provides a simplified client HTTP API known as **HttpClient** which is based on top of XMLHttpRequest interface. This client is avaialble from `@angular/common/http` package.
998
+
Most of the Front-end applications communicate with backend services over `HTTP` protocol using either `XMLHttpRequest` interface or the `fetch()` API. Angular provides a simplified client HTTP API known as `HttpClient` which is based on top of XMLHttpRequest interface. This client is avaialble from `@angular/common/http` package.
1000
999
You can import in your root module as below,
1001
1000
1002
1001
```javascript
@@ -1012,9 +1011,9 @@ You can download the PDF and Epub version of this repository from the latest run
1012
1011
1013
1012
**[⬆ Back to Top](#table-of-contents)**
1014
1013
1015
-
37. ### Explain on how to use HttpClient with an example?
1016
-
Below are the steps need to be followed for the usage of HttpClient.
1017
-
1. Import HttpClient into root module:
1014
+
37. ### Explain on how to use `HttpClient` with an example?
1015
+
Below are the steps need to be followed for the usage of `HttpClient`.
1016
+
1. Import `HttpClient` into root module:
1018
1017
```javascript
1019
1018
import { HttpClientModule } from '@angular/common/http';
1020
1019
@NgModule({
@@ -1027,8 +1026,8 @@ You can download the PDF and Epub version of this repository from the latest run
1027
1026
})
1028
1027
export class AppModule {}
1029
1028
```
1030
-
2. Inject the HttpClient into the application:
1031
-
Let's create a userProfileService(userprofile.service.ts) as an example. It also defines get method of HttpClient
1029
+
2. Inject the `HttpClient` into the application:
1030
+
Let's create a userProfileService(`userprofile.service.ts`) as an example. It also defines get method of `HttpClient`:
1032
1031
```javascript
1033
1032
import { Injectable } from '@angular/core';
1034
1033
import { HttpClient } from '@angular/common/http';
@@ -1045,7 +1044,7 @@ You can download the PDF and Epub version of this repository from the latest run
1045
1044
}
1046
1045
```
1047
1046
3. Create a component for subscribing service:
1048
-
Let's create a component called UserProfileComponent(userprofile.component.ts) which inject UserProfileService and invokes the service method,
1047
+
Let's create a component called UserProfileComponent(`userprofile.component.ts`), which injects `UserProfileService` and invokes the service method:
1049
1048
```javascript
1050
1049
fetchUserProfile() {
1051
1050
this.userProfileService.getUserProfile()
@@ -1061,20 +1060,20 @@ You can download the PDF and Epub version of this repository from the latest run
1061
1060
**[⬆ Back to Top](#table-of-contents)**
1062
1061
1063
1062
38. ### How can you read full response?
1064
-
The response body doesn't may not return full response data because sometimes servers also return special headers or status code which are important for the application workflow. Inorder to get full response, you should use observe option from HttpClient,
1063
+
The response body doesn't or may not return full response data because sometimes servers also return special headers or status code, which are important for the application workflow. In order to get the full response, you should use `observe` option from `HttpClient`:
Now HttpClient.get() method returns an Observable of typed HttpResponse rather than just the JSON data.
1071
+
Now `HttpClient.get()` method returns an Observable of typed `HttpResponse` rather than just the `JSON` data.
1073
1072
1074
1073
**[⬆ Back to Top](#table-of-contents)**
1075
1074
1076
1075
39. ### How do you perform Error handling?
1077
-
If the request fails on the server or failed to reach the server due to network issues then HttpClient will return an error object instead of a successful reponse. In this case, you need to handle in the component by passing error object as a second callback to subscribe() method.
1076
+
If the request fails on the server or fails to reach the server due to network issues, then `HttpClient` will return an error object instead of a successful reponse. In this case, you need to handle in the component by passing `error` object as a second callback to `subscribe()` method.
1078
1077
1079
1078
Let's see how it can be handled in the component with an example,
1080
1079
```javascript
@@ -1086,7 +1085,7 @@ You can download the PDF and Epub version of this repository from the latest run
1086
1085
);
1087
1086
}
1088
1087
```
1089
-
It is always a good idea to give the user some meaningful feedback instead of displaying the raw error object returned from HttpClient.
1088
+
It is always a good idea to give the user some meaningful feedback instead of displaying the raw error object returned from `HttpClient`.
0 commit comments