Wednesday 24 June 2020

AngularJS Interview Questions And Answers


What Is AngularJS And Why Should You Use It?

1. What Is AngularJS?

Answer: It has been developed by one of the biggest technology giants Google. It is a JavaScript framework that helps you to create dynamic Web applications.
It supports to use HTML as the template language and enables the developer to create extended HTML tags that help to represent the application’s components more clearly. These tags make the code efficient by reducing the lines of code that a developer may need to write when using JavaScript.
It is open-source and licensed under the Apache License version 2.0.
It helps to develop a maintainable architecture that is easy to test at the client-end.

2. Explain The Steps Involved In The Boot Process For AngularJS?

Answer: Whenever a web page loads in the browser, the following steps execute in the background.
First, the HTML file containing the code gets loaded into the browser. After that, the JavaScript file mentioned in the HTML code gets loaded. It then creates a global object for angular. Now, the JavaScript which displays the controller functions gets executed.
In this step, AngularJS browses the complete HTML code to locate the views. If the same is available, then Angular links it to the corresponding controller function.
In this step, AngularJS initiates the execution of required controller functions. Next, it populates the views with data from the model identified by the controller. With this the page is ready.

3. Is AngularJS a library, framework, plugin or browser extension?

Answer:  AngularJS is a first-class JavaScript framework which allows you to build well structured, easily testable and maintainable front-end applications.

It is not a library since the library provides you limited functionality or has dependencies to other libraries.

It is not a plugin or browser extension since it is based on JavaScript and compatible with both desktop and mobile browsers.

4. What is the factory method in AngularJS?

Answer: Factory method is used for creating a directive. It is invoked when the compiler matches the directive for the first time. We can invoke the factory method using $injector.invoke.

Syntax: module.factory( ‘factory name’, function );
Result: When declaring factory name as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.

5. What is ng-app, ng-init, and ng-model?

Answer: ng-app: Initializes application.
ng-model: Binds HTML controls to application data.
ng-Controller: Attaches a controller class to view.
ng-repeat: Bind repeated data HTML elements. It’s like a for a loop.
ng-if: Bind HTML elements with the condition.
ng-show: Used to show the HTML elements.
ng-hide : Used to hide the HTML elements.
ng-class: Used to assign CSS class.
ng-src: Used to pass the URL image etc.

6. What are the Filters in AngularJS?

Answer: Filters are used to format data before displaying it to the user.

They can be used in view templates, controllers, services and directives.

You can also create your own filters.

There are some built-in filters provided by AngularJS like Currency, Date, Number, OrderBy, Lowercase, Uppercase, etc.

7. Explain the validation feature in AngularJS?

Answer: AngularJS has some built-in validation around HTML5 input variables (text, number, URL, email, radio, checkbox) and some directives (required, pattern, minlength, maxlength, min, max).

If you want to create your own validation, it is just as simple as creating a directive to perform your validation.

8. How to read data from the server?

Answer:$https is an AngularJS service for reading data from remote servers.

$https.get(URL) is the function to use for reading server data.

9. What are different ways to create service in AngularJS?

Answer: There are five types to create service in AngularJS.

1. Service

2. Factory

3. Provider

4. Value

5. Constant

10. What is $ watch?

Answer: When we create a data binding from somewhere in our view to a variable, it means on the $scope object, AngularJS creates a “watch” internally. 

A watch means that AngularJS watches changes in the variable on the $scope object.

11. Explain What String Interpolation Is In AngularJS?

Answer: During the compilation process, AngularJS compiler matches the text and attributes using interpolate service to see if it contains embedded expressions.

During the normal, digest life cycle, these expressions are updated and registered as watches.   ( tableau training videos )

12. What are the exit codes in Node.js? List some exit codes?

Answer: Exit codes are specific codes that are used to end a “process” (a global object used to represent a node process).

Examples of exit codes include:

Unused
Uncaught Fatal Exception
Fatal Error
Non-function Internal Exception Handler
Internal Exception handler Run-Time Failure
Internal JavaScript Evaluation Failure 

13. Why is consistent style important and what tools can be used to assure it?

Answer: Consistent style helps team members modify projects easily without having to get used to a new style every time. Tools that can help include Standard and ESLint.

14. What Are The Main Features Of AngularJS?

Answer: Here is the list of AngularJS features that makes it the hottest tech for web dev.

Data-binding – Handles synchronization of data across model, controllers, and view.
Scope – Object representing the model, acts as a glue layer between controller and view.
Controllers – JS functions bound to the scope object.
Services – Substitutable objects that are wired together using dependency injection. e.g. $location service.
Filters – Formats the value of an expression for displaying to the user. e.g., uppercase, lowercase.
Directives – These are extended HTML attributes start with the “ng-” prefix. e.g., the ng-app directive used to initialize the angular app.
Templates – HTML code including AngularJS specific elements and attributes.
Routing – It’s an approach to switch views.
MVC pattern – A design pattern made up of three parts.
Model – Represents data, could be static data from a JSON file or dynamic data from a database.
View – Renders data for the user.
Controller – Gives control over the model and view for collating information to the user.
Deep linking – Enables the encoding of the application state in the URL and vice versa.
Dependency injection – A design pattern to let the components injected into each other as dependencies.

15. Explain callback in Node.js?

Answer: A callback function is called at the completion of a given task. This allows other code to be run in the meantime and prevents any blocking. Being an asynchronous platform, Node.js heavily relies on callback. All APIs of Node are written to support callbacks.

 
16. Explain What Directives Are? Mention Some Of The Most Commonly Used Directives In AngularJS Application?

Answer: AngularJS extends the behavior of HTML and DOM elements with new attributes called Directives. It directs the AngularJS’s HTML compiler ($compile) to attach a unique action to that DOM element. This AngularJS component starts with the prefix “ng.”

Following is the list of AngularJS built-in directives.
ng-bind – The ng-bind directive tells AngularJS to replace the content of an HTML element with the value of a given variable, or expression.

If there is any change in the value of the given variable or expression, then the content of the specified HTML element will also be updated accordingly. It supports one-way binding only.
ng-model – This directive is used to bind the value of HTML controls (input, select, text area) to application data. It is responsible for linking the view into the model. Directives such as ‘input’, ‘text area’, and ‘select’ require it. It supports two-way data binding.
ng-class – This directive dynamically binds one or more CSS classes to an HTML element. The value of the ng-class directive can be a string, an object, or an array.
ng-app – Just like the “Main()” function of Java language, this directive marks the beginning of the application to AngularJS’s HTML compiler ($compile). If we do not use this directive first, an error gets generated.
ng-init – This is used to initialize the application data so that we can use it in the block where it is declared. If an application requires local data like a single value or an array of values, this can be achieved using the ng-init directive.
ng-repeat – This repeats a set of HTML statements for the defined number of times. The set of HTML statements will be repeated once per item in a collection. This collection must be an array or an object.
We can even create custom directives and use them in our AngularJS Application. ( oracle apex training online )

17. What Are Different Ways To Invoke A Directive?
Answer:

There are four different ways to invoke a directive in an angular application. They are as follows.

1) As an attribute:

2) As a class:

3) As an element:

4) As a comment:

20. What Is “$RootScope” In AngularJS?

Answer: Every AngularJS application has a “$rootScope” that is the top-most scope created on the DOM element. An app can have only one $rootScope which will be shared among all its components. It contains the ng-app directive. Every other scope is its child scope. It can watch expressions and propagate events. Using the root scope, we can set the value in one controller and read it from the other controller.( puppet training ) 

21. Explain The Concept Of Scope Hierarchy? How Many Scopes Can An Application Have?

Answer: Every AngularJS application consists of one root scope but may have several child scopes. As child controllers and directives create new child scopes, they get attached to the application. These new scopes get added as children of their parent scope. Similar to DOM, they also create a hierarchical structure.

22. How Is AngularJS Compiled?

Answer: Angular’s HTML compiler allows you to teach the browser, new HTML syntax. It enables the developer to attach new behaviors or attributes to any HTML element called directives. AngularJS compilation process takes place in the web browser itself. It does not involve any server-side or pre-compilation step.

AngularJS uses <$compiler> service to compile the angular HTML page. Its compilation begins after the HTML page (static DOM) is fully loaded.

It occurs in two phases.

Compile – It looks into the entire DOM and collects all of the directives. The result is a linking function.
Link – It combines the directives with a scope and produces a live view. Any changes in the get reflected in the view and any operations done by the user in the view gets reflected in the.
The concept of compile and link has come from the C language. Here the code is compiled first and then linked.

23. How Is AngularJS Compilation Different From Other JavaScript Frameworks?

Answer: Javascript frameworks like backbone and jQuery process the template as a string and returns the result as a string. You have to dump this resulting string into the DOM where you wanted it with innerHTML().

AngularJS process the template in another way. It directly works on HTML DOM rather than strings and manipulates it as required. It uses two-way data binding between the model and view to sync the data.

24. What is data binding? Explain two-way data binding?

Answer:
1. Data binding means automatic synchronous of data between model and view components.

2. AngularJS supports two-way data binding, it treats the model as a single source of truth and view is the projection of the model. It means when we change model view gets to reflect and vice-versa.

3. In the traditional concept, HTML pages are decided by interacting with server-side program and as we using single page application, pages are decided without any server-side interaction. So required part of the page will be updated. ( hadoop training videos )

25. Which is the core module in AngularJS?
Answer: ng” is the core module in AngularJS and this module will be loaded by default when the angular application has started.

26. Explain factory methods in AngularJS?
Answer: Factory methods are used for creating a directive. It can be invoked only once that is when compiler matches the directive.

27. What Is $RouteProvider In AngularJS?
Answer: $routeProvider is the primary service which set the configuration of URLs, map them to the corresponding HTML page or ng-template, and attach a controller with the same.

Let’s see the following example:

var mainApp = angular.module(“mainApp”, [‘ngRoute’]);
mainApp.config([‘$routeProvider’, function($routeProvider) {
$routeProvider.
when(‘/addEmployee’, {
templateUrl: ‘addEmployee.htm’, controller: ‘AddEmployeeController’

otherwise({
redirectTo: ‘/addEmployee’

Following are the important points to be considered in the above example.

routeProvider is defined as a function under the config of the mainApp module using a key as ‘$routeProvider.’
$routeProvider.when defines a URL “/addEmployee” which is then mapped to “addEmployee.htm”. This should be present in the same path as the main HTML page.
“otherwise” is used to set the default view.
“controller” is used to set the corresponding controller for the view.
Back to top

28. What Is Data Binding? How Many Types Of Data Binding Directives Are Provided By AngularJS?

Answer: Data binding is the connection bridge between view and business logic (view model) of the application. Data binding in AngularJs is the automatic synchronization between the model and view. When the model changes, the view is automatically updated and vice versa. AngularJs support one-way binding as well as two-way binding. ( data science online training )

29. What are typings in Angular?

Answer: Typings is a way of installing the Typescript definitions using typings.json file, as it is necessary as the browser does not understand typescript natively and hence it must be transpiled first before rendering.

30. What are module loaders in Angular?

Answer: Module loaders in Angular are used to bundle different modules that contain their dependencies along with angular components into one bundle or multiple bundles (For lazy loading) and load them in the browser.

31. What is the use of systems? How is webpack better to use in Angular?

Answer: System is a client-side module bundler in angular as it loads modules (components and other files) on demand instead of loading an entire application at startup.
This largely reduces load times while starting up the app.
The upside of Webpack over Systems is that it bundles and creates a single file called bundle.js, which contains HTML, CSS, and JS, etc.
While the initial load time might take a few seconds once the app is cached it becomes lightning-fast and will lead to a large boost in performance.

32. What Is An Auto Bootstrap Process In AngularJS?
Answer: AngularJS initializes automatically upon the “DOMContentLoaded” event or when the browser downloads the angular.js script and at the same time document.readyState is set to ‘complete.’ At this point, AngularJS looks for the ng-app directive which is the root of the Angular app compilation process.

If the ng-app directive is located, then AngularJS will do the following.

Load the module associated with the directive.
Create the application injector.
Compile the DOM starting from the ng-app root element.
We term this process as Auto-bootstrapping.

33. What Is $Scope In AngularJS?

Answer: It is an application object. And behaves as the owner of the apps variables and functions. Scope object has access to both View and controller. Thus it works as a medium of communication between both of them. This object contains both data and functions. We can use it to access model data of the controller.

Following are the key characteristics of the scope object.
It provides observers to watch for all the model changes.
Provides the ability to propagate model changes through the application as well as outside the system to other associated components.
Scopes can be nested in such a way that they can isolate functionality and model properties.
Provides an execution environment in which expressions are evaluated.

34. Mention what are the styling form that model adds to CSS classes?
Answer:
the model adds these CSS classes to allow styling of form as well as control:

1. ng- valid

2. ng-invalid

3. ng-pristine

4. ng-dirty


35. How to use jQuery with AngularJS?

Answer: By default, AngularJS use SQLite which is the subset of jQuery.

If you want to use jQuery then simply load the jQuery library before loading the AngularJS.

By doing so, Angular will skip SQLite and will start to use the jQuery library.

36. What Is The Manual Bootstrap Process In AngularJS?

Answer: Sometimes we may need to manually initialize the Angular app to have more control over the initialization process. We can do that by using angular.bootstrap() function within angular.element(document).ready() function. AngularJS fires this function when the DOM is ready for manipulation.

The angular.bootstrap() function takes two parameters, the document, and module name injector.

37. What Is A Controller In AngularJS?

Answer: A Controller is a set of JavaScript functions which is bound to a specified scope, the ng-controller directive. Angular creates a new instance of the Controller object to inject the new scope as a dependency. The role of the Controller is to expose data to our view via $scope and add functions to it, which contains business logic to enhance view behavior.

Controller Rules.
A Controller helps in setting up the initial state of the scope object and define its behavior.
The Controller should not be used to manipulate the DOM as it contains only business logic. Instead, for managing the DOM, we should use data binding and directives.
Do not use Controllers to format input. Instead, using angular form controls is recommended for that.
Controllers should not be used to share code or states. Instead, use angular services for it.
Steps For Creating A Controller.
It needs ng-controller directive.
Next step is to add Controller code to a module.
Name your Controller based on functionality. Its name should follow the camel case format (i.e., SampleController).
Set up the initial state of the scope object.
Declaring a Controller using ng-Controller directive-

38. What Is The Difference Between The $Watch, $Digest, And $ Apply?
Answer: In AngularJS $scope object is having different functions like $watch(), $digest() and $apply() and we will call these functions as central functions. The AngularJS central functions $watch(), $digest(), and $apply() are used to bind data to variables in view and observe changes happening in variables.
 $Watch() –
The use of this function is to observe changes in a variable on the $scope. It triggers a function call when the value of that variable changes. It accepts three parameters: expression, listener, and equality object. Here, listener and equality objects are optional parameters.  ( python online training )



Don’t forget to leave your feedback and comments below!

Regards
Sujeet Bhujbal


— — — — — — — — — — — — — — — — — — — — — — — — — —
Blog: www.sujeetbhujbal.com
Personal Website :-http://sujeetbhujbal.wordpress.com/
CodeProject:-https://www.codeproject.com/Members/SujitBhujbal
CsharpCorner:-http://www.c-sharpcorner.com/Authors/sujit9923/sujit-bhujbal.aspx
Linkedin :-http://in.linkedin.com/in/sujitbhujbal
Medium: — https://medium.com/@SujeetBhujbal
— — — — — — — — — — — — — — — — — — — — — — — — 

Best Investment Options in India

Investments are important because in today’s world, just earning money is not enough. Investments done today will definitely produce huge returns in the coming years provided You choose the right investment products and be invested in those for long term for wealth creation. You should invest that money smartly to get good returns out of it.

Major assets classes where one can invest are:-

1. Emergency Fund

There’s plenty of research to show that people don’t have enough cash on hand to meet emergency expenses even as little as Rs 50000. How much should you have? There’s no easy answer but some people do recommend 6 months of your living expenses. You can park this money in a liquid fund. Here’s a handy post 11:

2. Fixed Deposit

A fixed deposit refers to an investment scheme that banks and non-banking financing companies provide. FDs offer greater returns on the principal invested when compared to the returns generated from a regular savings account.

Nowadays very few banks give more than 6% interest on fixed deposits. Please check the below bank with more than a 6% fixed deposit.

3. Recurring deposit

A type of term deposit offered by nearly every major bank in India, a recurring deposit (RD) helps people with regular incomes deposit a fixed monthly amount and earn interest at a rate that, on average, ranges from five to eight percent.

Nowadays very few banks give more than 6% interest on recurring deposits. Please check the below bank with more than a 6% recurring deposit.

4.Post Office Recurring Deposit

Post Office Recurring Deposit account can be opened by Indian citizens at any post office and has a fixed lock-in period of five years. The scheme typically offers an interest rate above seven percent per annum. and has a minimum deposit amount of only Rs 10 per month (there is no maximum limit) payable through cash, cheque, or bank transfer. This type of investment is completely risk-free and since it is backed by the government, the capital completely secure.

The rate of interest offered on the RD scheme in the post office in 2019 is 7.2% p.a. Such interest rate makes it one of the most preferred investment options available.

5. High-Interest Saving Account

Private banks offer higher interest rate but they have some hidden clauses as well. I did research on major Indian banks to find the best savings account in India. You should also consider technology, customer support, and extra benefits that banks provide a savings account.

6. Stock Investment

You can open Demat account within 3 days online with minimum charges of 300rs

1. Zerodha https://zerodha.com/

2. Upstock www.upstox.com/‎

3. ICICI Direct https://www.icicidirect.com/

4. Kotak

Best Stocks to Consider Investing for Long Term

Key:

Value: Total amount invested by the Funds in the particular stock, in Millions of Rupees

Avg Share: Average of the percentage of portfolio value of the stock in all the funds it is present in

Funds: Number of Funds which have the stock as a component in it

Points: A metric derived by the sum of the percentage of portfolio value of the stock in all Funds

Dividend stocks

Not all stocks that pay dividends are good. There are two criteria which makes a good dividend stock:

  • Consistent dividend payout.
  • Consistent growth in the dividend paid.

Buy dividend-paying stocks, and hold them for the long term. What is the point about the ‘long term’? A stock that is yielding 0.5% at the time of purchase, can yield much higher with the time.

Please find below high yield dividend stock

7. Mutual Fund

You can open a mutual fund account online. Please check below the service provider

  1. Groww App https://groww.in/
  2. Zerodha Coin https://coin.zerodha.com/
  3. Upwardly https://www.upwardly.in/en/

Equity Schemes

Equity funds will be further broken down into 10 subcategories listed below.

  1. Multi-cap fund — These schemes invest at least 65% of the total assets in equity and equity-related instruments.
  2. Large-cap Fund — These schemes are required to make a minimum investment of 80% of the total assets in the equity and equity-related instruments of large-cap companies.
  3. Large and Mid-cap fund — The schemes need to make a minimum investment of at least 35% of total assets in both large-cap and mid-cap companies each.
  4. Mid-cap funds — 65% of the total assets should be invested in the equity and equity-related instruments of mid-cap companies for this scheme.
  5. Small-Cap fund — The investment required by the scheme in equity and equity-related instrument of small-cap companies is 65% of the total assets.
  6. Dividend Yield funds — This scheme primarily investments in dividend-yielding stocks. The minimum investment required is 65% of the total assets in equity instruments.

Please find below Top Performing Mutual funds to invest

8. Stock Market Investment using Smallcase

Smallcase is a simple & easy way to invest in ready-made stock portfolios. Choose from several intelligently-weighted portfolios of stocks/shares & ETFs. Based on a platform created by Bengaluru-based Smallcase Technologies, this allows investors to invest in professionally researched, diversified theme-based portfolios with their existing trading and demat accounts

How it works

First, access the smallcase platform offered by the broker. Next, choose a theme of your liking. You can see what stocks make up the portfolio and in what proportion, and the investment rationale.
Once you have finalized the selection, you can buy the smallcase. The minimum amount depends on the price and weightage of individual stocks in the portfolio. The platform will place buy orders for all stocks, which will be executed immediately depending on liquidity.
Brokers charge a one-time fee of Rs 100 when you first invest in a smallcase. The transaction also attracts the usual brokerage charges. There will be no additional fees for further orders in the same smallcase, apart from the cost of executing the trades.

All small cases are rebalanced periodically — mostly quarterly — to ensure the portfolio only constitutes companies that remain true to the broader theme.

Please find below smallcases based on the theme

9. Gold Investment

Gold investment can be done in many forms like buying jewelry, coins, bars, gold exchange-traded funds, Gold funds, sovereign gold bond scheme, etc. . If you are not in favor of holding physical gold, you can go for other alternatives ETFs, gold funds or SGBs

How to Invest in Gold: Best Gold Investment Plan

1.Gold ETFs (Exchanged Traded Funds) are similar to buying physical gold but the only difference is you don’t actually buy the physical gold. You don’t have to go through the hassles of storing the physical gold, instead, the gold bought is stored in Demat (paper) format. On the other hand, gold funds deal with investing in gold mining companies.

2.Sovereign Gold Bonds

Sovereign Gold Bonds are the safest way to buy digital Gold as they are issued by the Reserve Bank of India on behalf of the Government of India with an assured interest of 2.50% per annum. The bonds are denominated in units of grams of gold with a basic unit of 1 gram.

Some of the Top Gold Funds in India

Based on the market scenario, some of the top gold funds that you can consider investing in are:

10. Real Estate Investment

Real estate investing needs a different strategic approach than purchasing a property for personal use. When you choose real estate as an investment strategy, you purchase a property to make a profit on it. In most cases, the investor rents out the property or resells it at a higher cost.

Every young person be it a girl or a boy, IT professional or marketing person, should invest in a property as early as possible In last few years, Indian real estate market has faced major hurdles. Though RERA is now in place, but this sector is not reviving.

We have other traditional options also like NPS , PPF . You can also invest in NPS and PPF

Note :- If you can’t do it yourself, hire an advisor

If you don’t have the time or patience to do all these things, you are better off hiring a fee-only Registered Investment Advisor. Stay away from mutual fund distributors, bank employees, relationship managers, and LIC agents, etc.

A fee-only advisor — meaning he has to put your best interest first. He doesn’t get any commissions from the manufacturer of the product. He only gets paid a fee by you. That way your interests and his interests are aligned.

Please check below websites or YouTube channels that I am following

  1. https://myinvestmentideas.com/
  2. https://www.jagoinvestor.com/
  3. https://www.safalniveshak.com/blog/
  4. https://www.youtube.com/user/pranjalkamra
  5. https://www.youtube.com/channel/UCPohbSYq4IXhv0yxiy-sT4g/videos
  6. https://www.youtube.com/channel/UCNknK104P7l5KqXMiI8sqFQ
  7. https://www.youtube.com/channel/UCZn38KmU8VEsupVPhrYonzg/featured

Happy investing!


Don’t forget to leave your feedback and comments below!

Regards
Sujeet Bhujbal


— — — — — — — — — — — — — — — — — — — — — — — — — —
Blog: www.sujeetbhujbal.com
Personal Website :-http://sujeetbhujbal.wordpress.com/
CodeProject:-https://www.codeproject.com/Members/SujitBhujbal
CsharpCorner:-http://www.c-sharpcorner.com/Authors/sujit9923/sujit-bhujbal.aspx
Linkedin :-http://in.linkedin.com/in/sujitbhujbal
Medium: — https://medium.com/@SujeetBhujbal
— — — — — — — — — — — — — — — — — — — — — — — —