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
+27-30
Original file line number
Diff line number
Diff line change
@@ -318,32 +318,32 @@ You can download the PDF and Epub version of this repository from the latest run
318
318
319
319
1.### What is Angular Framework?
320
320
321
-
Angular is a **TypeScript-based open-source** front-end platform that makes it easy to build applications with in web/mobile/desktop. The major features of this framework such as declarative templates, dependency injection, end to end tooling, and many more other features are used to ease the development.
321
+
Angular is a **TypeScript-based open-source** front-end platform that makes it easy to build web, mobile and desktop applications. The major features of this framework include declarative templates, dependency injection, end to end tooling which ease application development.
322
322
323
323
**[⬆ Back to Top](#table-of-contents)**
324
324
325
325
2.### What is the difference between AngularJS and Angular?
326
326
Angular is a completely revived component-based framework in which an application is a tree of individual components.
327
327
328
-
Some of the major difference in tabular form
328
+
Here are some of the major differences in tabular format:-
329
329
330
330
| AngularJS | Angular |
331
331
|---- | ---------
332
332
| It is based on MVC architecture| This is based on Service/Controller|
333
-
| It uses JavaScript to build the application|Introduced the TypeScript to write the application|
333
+
| It uses JavaScript to build the application|Uses TypeScript to build the application|
334
334
| Based on controllers concept| This is a component based UI approach|
335
-
|Not a mobile friendly framework| Developed considering mobile platform|
336
-
|Difficulty in SEO friendly application development| Ease to create SEO friendly applications|
335
+
|No support for mobile platforms| Fully supports mobile platforms|
336
+
|Difficult to build SEO friendly application| Ease to build SEO friendly applications|
337
337
338
338
**[⬆ Back to Top](#table-of-contents)**
339
339
340
340
3.### What is TypeScript?
341
-
TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes, async/await, and many other features, and compiles to plain JavaScript. Angular built entirely in TypeScript and used as a primary language.
342
-
You can install it globally as
341
+
TypeScript is a strongly typed superset of JavaScript created by Microsoft that adds optional types, classes, async/await and many other features, and compiles to plain JavaScript. Angular is written entirely in TypeScript as a primary language.
342
+
You can install TypeScript globally as
343
343
```cmd
344
344
npm install -g typescript
345
345
```
346
-
Let's see a simple example of TypeScript usage,
346
+
Let's see a simple example of TypeScript usage:-
347
347
```typescript
348
348
function greeter(person: string) {
349
349
return "Hello, " + person;
@@ -358,17 +358,17 @@ You can download the PDF and Epub version of this repository from the latest run
358
358
**[⬆ Back to Top](#table-of-contents)**
359
359
360
360
4. ### Write a pictorial diagram of Angular architecture?
361
-
The main building blocks of an Angular application is shown in the below diagram
361
+
The main building blocks of an Angular application are shown in the diagram below:-
362
362

363
363
364
364
**[⬆ Back to Top](#table-of-contents)**
365
365
366
366
5. ### What are the key components of Angular?
367
-
Angular has the below key components,
368
-
1. **Component:** These are the basic building blocks of angular application to control HTML views.
369
-
2. **Modules:** An angular module is set of angular basic building blocks like component, directives, services etc. An application is divided into logical pieces and each piece of code is called as "module" which perform a single task.
370
-
3. **Templates:** This represent the views of an Angular application.
371
-
4. **Services:** It is used to create components which can be shared across the entire application.
367
+
Angular has the key components below,
368
+
1. **Component:** These are the basic building blocks of an Angular application to control HTML views.
369
+
2. **Modules:** An Angular module is a set of angular basic building blocks like components, directives, services etc. An application is divided into logical pieces and each piece of code is called as "module" which perform a single task.
370
+
3. **Templates:** These represent the views of an Angular application.
371
+
4. **Services:** Are used to create components which can be shared across the entire application.
372
372
5. **Metadata:** This can be used to add more data to an Angular class.
373
373
374
374
**[⬆ Back to Top](#table-of-contents)**
@@ -631,17 +631,20 @@ You can download the PDF and Epub version of this repository from the latest run
631
631
**[⬆ Back to Top](#table-of-contents)**
632
632
633
633
15. ### What is the difference between constructor and ngOnInit?
634
-
TypeScript classes has a default method called constructor which is normally used for the initialization purpose. Whereas ngOnInit method is specific to Angular, especially used to define Angular bindings. Even though constructor getting called first, it is preferred to move all of your Angular bindings to ngOnInit method.
635
-
In order to use ngOnInit, you need to implement OnInit interface as below,
634
+
The **Constructor** is a default method of the class that is executed when the class is instantiated and ensures proper initialisation of fields in the class and its subclasses. Angular, or better Dependency Injector (DI), analyses the constructor parameters and when it creates a new instance by calling new MyClass() it tries to find providers that match the types of the constructor parameters, resolves them and passes them to the constructor.
635
+
**ngOnInit** is a life cycle hook called by Angular to indicate that Angular is done creating the component.
636
+
Mostly we use ngOnInit for all the initialization/declaration and avoid stuff to work in the constructor. The constructor should only be used to initialize class members but shouldn't do actual "work".
637
+
So you should use constructor() to setup Dependency Injection and not much else. ngOnInit() is better place to "start" - it's where/when components' bindings are resolved.
636
638
637
639
```typescript
638
640
export class App implements OnInit{
639
-
constructor(){
641
+
constructor(private myService: MyService){
640
642
//called first time before the ngOnInit()
641
643
}
642
644
643
645
ngOnInit(){
644
646
//called after the constructor and called after the first ngOnChanges()
647
+
//e.g. http call...
645
648
}
646
649
}
647
650
```
@@ -1540,23 +1543,17 @@ You can download the PDF and Epub version of this repository from the latest run
1540
1543
**[⬆ Back to Top](#table-of-contents)**
1541
1544
1542
1545
77. ### What is JIT?
1543
-
Just-in-Time (JIT) is a type of compilation that compiles your app in the browser at runtime. JIT compilation is the default when you run the ng build (build only) or ng serve (build and serve locally) CLI commands. i.e, the below commands used for JIT compilation,
1544
-
1545
-
```cmd
1546
-
ng build
1547
-
ng serve
1548
-
```
1546
+
Just-in-Time (JIT) is a type of compilation that compiles your app in the browser at runtime. JIT compilation was the default until Angular 8, now default is AOT. When you run the ng build (build only) or ng serve (build and serve locally) CLI commands, the type of compilation (JIT or AOT) depends on the value of the aot property in your build configuration specified in angular.json. By default, aot is set to true.
1549
1547
1550
1548
**[⬆ Back to Top](#table-of-contents)**
1551
1549
1552
1550
78. ### What is AOT?
1553
-
Ahead-of-Time (AOT) is a type of compilation that compiles your app at build time. For AOT compilation, include the `--aot` option with the ng build or ng serve command as below,
1554
-
1551
+
Ahead-of-Time (AOT) is a type of compilation that compiles your app at build time. This is the default starting in Angular 9. When you run the ng build (build only) or ng serve (build and serve locally) CLI commands, the type of compilation (JIT or AOT) depends on the value of the aot property in your build configuration specified in angular.json. By default, aot is set to true.
1552
+
1555
1553
```cmd
1556
-
ng build --aot
1557
-
ng serve --aot
1554
+
ng build
1555
+
ng serve
1558
1556
```
1559
-
**Note:** The ng build command with the --prod meta-flag (`ng build --prod`) compiles with AOT by default.
1560
1557
1561
1558
**[⬆ Back to Top](#table-of-contents)**
1562
1559
@@ -2225,7 +2222,7 @@ You can download the PDF and Epub version of this repository from the latest run
2225
2222
**[⬆ Back to Top](#table-of-contents)**
2226
2223
2227
2224
121. ### What is a builder?
2228
-
A builder function ia a function that uses the `Architect API` to perform a complex process such as "build" or "test". The builder code is defined in an npm package. For example, BrowserBuilder runs a webpack build for a browser target and KarmaBuilder starts the Karma server and runs a webpack build for unit tests.
2225
+
A builder function is a function that uses the `Architect API` to perform a complex process such as "build" or "test". The builder code is defined in an npm package. For example, BrowserBuilder runs a webpack build for a browser target and KarmaBuilder starts the Karma server and runs a webpack build for unit tests.
2229
2226
2230
2227
**[⬆ Back to Top](#table-of-contents)**
2231
2228
@@ -4594,4 +4591,4 @@ You can download the PDF and Epub version of this repository from the latest run
4594
4591
274. ### What is content projection?
4595
4592
Content projection is a pattern in which you insert, or project, the content you want to use inside another component.
4596
4593
275. ### What is ng-content and its purpose?
4597
-
The ng-content is used to insert the content dynamically inside the component that helps to increase component reusability.
4594
+
The ng-content is used to insert the content dynamically inside the component that helps to increase component reusability.
0 commit comments