Sunday, August 19, 2018

MyDesq

1. dependency Injection in angular JS
2. How to format the string in angular
3. How to Send value from one component to other component without services
4. Then in services
5. how to inherit the class in typescript
6. if I want to change the index.html to home.html then where i have to change.

Ans : Angular-cli.json inside app

"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",

],

7. how to use Interface in typescript
8. what are the configuration files in angular2
  1. tsconfig.json - This file is used to give the options about TypeScript used for the Angular JS project.
  2. package.json  - contains the dependency and development dependencies name and version/
  3. systemjs.config.json - This file contains the system files required for Angular JS application. This loads all the necessary script files without the need to add a script tag to the html pages.
  
9. Observable and subject
Ans : https://interview-preparation-for-you.blogspot.com/2018/02/difference-between-subject-and.html
10. calling the http service(Code)
11. parameter of http get service

get take two parameteres url and parameter const opts = { params: new HttpParams({fromString: "_page=1&_limit=10"}) }; return this.httpClient.get("http://server.com/api/products", opts);
12. View Child
https://interview-preparation-for-you.blogspot.com/2018/02/passing-data-from-child-to-parent-using.html
13. Shared Module in angular

Ans : You can put commonly used directives, pipes, and components into one module and then import just that module wherever you need it in other parts of your app.
14. How to send the Json object as parameter to http services that can be recieved as query string.
  1. Take the JSON object and convert it to string (JSON.stringify)
  2. Take the string and encode it in Base64 (you can find some useful info on this here
  3. Append it to the URL and make the GET call
  4. Reverse the process. decode and parse it into an object
15. how to format the response in angular
Ans: using interface you can format the response if it is customized than you can use map function.
16. how to send the query string parameter to http services

A set of parameters attached to the end of the URL is called Query Parameters. They are appended to the URL by adding ‘?’ at the end of the URL. In addition to that, they are followed immediately with a key-value pair(Query Parameter).
  HttpParams()
We add the URL parameters using the helper class HttpParams.  The HttpParams is passed as one of the arguments to HttpClient.get method.

To use HttpParams, you need to import it first as shown below.
 
import { HttpClient,HttpParams } from '@angular/common/http';
 
Then create an instance of the HttpParams class.

const params = new HttpParams()
  .set('page', PageNo)
  .set('sort', SortOn);
 
And then call the httpClient.get method passing the params as the argument.
 
return this.httpClient.get(this.baseURL + 'users/' + userName + '/repos',{params})
 

17. what is tuple

Ans : https://interview-preparation-for-you.blogspot.com/2017/11/how-to-use-two-object-in-single-view.html
18. angular 2 vs angular 4 vs angular 5 vs angular 6.
19. Change detection strategy

Ans : https://medium.com/@bencabanes/angular-change-detection-strategy-an-introduction-819aaa7204e7
20. Difference between ng-for and ng-for-of
1.     The [ngFor] is not a type safe
2.     The [NgForOf] is a type Safe
3.     The [NgFor] directive instantiates a template once per item from iterate
4.     The [ngFor] and [ngForOf] are actually the selectors of the [NgForOf] directive and it is not two distinct things
5.     The [ngFor] will be works like as collections
6.     The [ngForOf] will be works like as generics

Example - ngFor

{{i}} - {{user.name}}
OR Example - ngForOf
{{i}} - {{user.name}}

No comments:

Followers

Link