Skip to content

Commit 916311c

Browse files
authored
Add answer
1 parent 37d0ed5 commit 916311c

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,51 @@ At this level an interviewer wants to know whether the interviewee is a coachabl
5555

5656

5757
### Familiarity of Basic Terminology
58-
1. What are the differences between AngularJS (angular 1.x) and Angular (Angular 2.x and beyond)?
59-
2. What is a component? Why would you use it?
58+
1. What are the differences between AngularJS (angular 1.x) and Angular (Angular 2.x and beyond)?
59+
**Ans:** Angular 2 is not the upgrade of angular 1. Angular 2 is completely rewritten.
60+
Angular 2 is using Typescript which is super set of javascript.
61+
Angular 1.x was not built with mobile support in mind, where Angular 2 is mobile oriented.
62+
Angular 1 core concept was $scope, and you will not find $scope in angular 2.0. Angular 2 is using zone.js to detect changes.
63+
Angular 1.x controllers are gone. We can say that controllers are replaced with “Components” in Angular 2.
64+
In Angular 2, local variables are defined using hash(#) prefix.
65+
Two-way data binding: ng-model replaced with [(ngModel)]
66+
Angular 2 is using Hierarchical Dependency Injection system which is major performance booster. Angular 2 implements unidirectional tree based change detection which again increases performance . As per ng-conf meetup, angular 2 is 5 times faster as compared to angular.
67+
In Angular 2, Structural directives syntax is changed. ng-repeat is replaced with *ngFor.
68+
2. What is a component? Why would you use it?
69+
**Ans:** We create “components” – which roughly means UI directives.
70+
Components have isolated scopes by default.
71+
They automatically use controllerAs syntax.
72+
They use controllers instead of link functions.
73+
The bindToController option is on by default.
74+
Here’s an example component directive:
75+
```
76+
app.directive('list', function() {
77+
return {
78+
scope: {
79+
items: '='
80+
},
81+
templateUrl: 'list.html',
82+
controller: function ListCtrl() {},
83+
controllerAs: '$ctrl',
84+
bindToController: true
85+
}
86+
});
87+
```
88+
It’s a simple component directive, with an isolated scope, binding, and a controller.
89+
90+
Here’s how you’ll write it with .component:
91+
```
92+
app.component('list', {
93+
bindings: {
94+
items: '='
95+
},
96+
templateUrl: 'list.html',
97+
controller: function ListCtrl() {}
98+
});
99+
```
100+
Not recommended: If you want a template-less directive, e.g. ng-click that doesn’t have a template or separate scope.
101+
For more Info: http://www.codelord.net/2015/12/17/angulars-component-what-is-it-good-for/
102+
60103
3. What is the minimum definition of a component?
61104
4. What is a module, and what does it contain?
62105
5. What is a service, and when will you use it?
@@ -283,4 +326,4 @@ On a press release, God expressed HIS apologies to send the author of this repo
283326
___________
284327

285328

286-
Few questions are inspired by [Yonet](https://github.com/Yonet/Angular-Interview-Questions), [codeProject](https://www.codeproject.com/Articles/1169073/Angular-Interview-Questions)
329+
Few questions are inspired by [Yonet](https://github.com/Yonet/Angular-Interview-Questions), [codeProject](https://www.codeproject.com/Articles/1169073/Angular-Interview-Questions)

0 commit comments

Comments
 (0)