Angular Features and Important Concepts

Angular has drastic and breakable changes than AngularJS in terms of coding style, speed and performance and mobile support. Angular features like Controllers have been replaced with Components and improved digest cycle along with new feature that make Angular a powerful client side framework.

This post is not to show the basic angular feature or guide through the basic concepts but the concepts that are important to learn and very useful.

 

A Taste from Angular Version 4

https://netbasal.com/a-taste-from-angular-version-4-50be1c4f3550

 

The Ultimate Angular CLI Reference Guide

https://www.sitepoint.com/ultimate-angular-cli-reference/

 

Understanding Angular modules (NgModule) and their scopes

https://medium.com/@cyrilletuzi/understanding-angular-modules-ngmodule-and-their-scopes-81e4ed6f7407

 

How to build and publish an Angular module

https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464

 

Injecting components dynamically in Angular

https://medium.com/@tudorgergely/injecting-components-dynamically-in-angular-2-3d36594d49a0

 

Highlight selected row in ngFor – Angular

In this Angular2 tutorial, we will see how to highlight selected row in a table using ngFor & ngClassdirective.

https://ciphertrick.com/2016/10/26/highlight-selected-row-in-ngfor-angular-2/

 

Angular ngFor – Learn all Features including trackBy, why is it not only for Arrays ?

http://blog.angular-university.io/angular-2-ngfor/

 

Http Interceptor : Intercepting HTTP requests and response in Angular

http://array151.com/blog/http-interceptor-angular4/

Nodejs Interview Questions

Important Interview Questions for Node.js

1) What is Nodejs ?

2) What is NPM ?

3) Different types of API’s exist in Node (api methods)?

4) What is event looping ?

5) What is event emmiter in node.js ?

6) What is asynchronous calls in Node.js ?

7) Suppose we have 5 apis, we have to hit fifth api when all four have been completed.How can we do it ?

8) What are promises ?

9) What is promise all in node.js ?

10) What is clustering in node js?

11) Core features in node.js ?

12) Can I send body params in GET request ? if yes then how ?

13)  What are middle-wares in node.js ?

14) What is the use of next in node.js ?

15) Different types of exit polls in node.js ?

16) Explain Process in node.js ? 

17) Why node is single threaded ?

18) New features in node.js ?

19) What are create, read streams ?

20) Inheritance in node.js ?

21) How can I secure my cookies in node.js ?

22) What is the passport in node.js ?

23) Best way to manage the session in node.js ?

24) What do you mean by child processes in node.js ?

25) What is the cross-domain problem ?

26) If I want to solve the cross-domain problem for only specific type of APIs , how can I do it ?

27) How can we integrate Third party APIs in node.js ?

28) Explain callback in node.js ?

29) What is callback-hell in node.js? how can I solve this?

30) How can we install local and global dependencies in node.js ?

31) What are streams in node.js ?  

32) Explain package.json file in node.js ?

33) What is the meaning of tilde and caret in package.json

34) How can we control versioning about packages in node.js ?

35) Difference between dependencies and dev dependencies ?

36) What is npm start ?

37) If I want to explain my own command with npm how can I do it ?

38) Explain logging in node.js ?

39) Name node.js framworks ?

40) What is express

41) How can we add the prefix in node.js apis?

42) Use of cookie-parser in node.js?

43) How to make APIs session less ?

Further Reading

Javascript Interview Questions

AngularJS Interview Questions

Forever : Never let you down

Forever is a node package used to run Node.js applications with monitoring. It keeps the server alive even when the server crash/stops. When the Node server is stopped due to some error or exception it will automatically start the server. It runs like a daemon on ubuntu Linux. So if the application dies forever brings it back. It will automatically start the server (Node.js application) when our linux server starts and ensure it stays running.

 Forever Setup

Forever can be installed using npm command. To install it globally

sudo npm -g install forever

The usage options for Forever expose four simple command line tasks: start, stop, stopall, list.

forever [start | stop | stopall | list] [options] script [script options]

Forever Options:

start    : Start script as a daemon
stop     : Stop the daemon script
stopall : Stop all running forever script
list      : List all running forever script

Now start server using forever command instead of node.

forever start server.js

To check server has started or not?

forever list
 [0] server.js [ 24597, 24596 ]

To kill that process we need simply

forever stop 0

More about its options read documentation available on Github and Npm website.

Nodemon : Code watcher and Auto-Reload

Nodemon run your server in watch mode, if there is any change it restart the application automatically. During development we need to restart the server manually for every change. To skip this hectic task of restarting server again and again, nodemon module is there. 

Features of Nodemon

  • Open source
  • Automatic apply changes with auto-restart the server
  • Detect default file extension to monitor
  • Requirable  in Node.js apps
  • Works with server applications or one-time run utilities

Installation

Nodemon can be installed using npm command.

We can install it globally by

npm install -g nodemon

It can also be installed locally

npm install nodemon --save-dev

Now run your server with nodemon command instead of node command.

nodemon your_app

For example if your app is server.js, you will run

nodemon server.js

 

References:

https://www.npmjs.com

Difference between Maven and Apache Ant

Build tools are programs to manage and automate build process of your application. By build process means compiling source code, linking the packages, bundle them into an executable binary.

Maven and Apache Ant are popular build tools from Apache.

Here are key some key differences in both tools:

Apache Ant            

Maven

Ant is flexible and does not impose coding conventions. You need to specify the source of code and the destination.

Maven uses conventions. It knows where your source code is automatically, as long as you follow these conventions. You don’t need to tell Maven where it is.

Ant is procedural. You have to tell Ant exactly what to do; tell it to compile, copy, then compress, etc.

Maven is declarative; All you have to do is create a pom.xml file and put your source in the default directory. Maven will take care of the rest.

Ant doesn’t have a lifecycle.

 

Maven has a lifecycle. You simply call mvn install and a series of sequential steps are executed.

In Ant, you would first have to JUnit JAR file is, then create a classpath that includes the JUnit JAR, then tell Ant where it should look for test source code, write a goal that compiles the test source and then finally execute the unit tests with JUnit.

Maven has intelligence about common project tasks. To run tests, simply execute mvn test, as long as the files are in the default location.

Ant is simply a build tool. 

Maven is more of project management tool.

Apache Ant

Maven

Apache Ant basic tasks

In the previous post, we have learned what is Apache Ant, its features and an example to create simple build file. This post will guide you other basic ant tasks that are frequently used to create and deploy packages.

Property

 Ant allows us to declare properties and assign values that can be used as variables

<property name="property_name" value="property_value"/>

And that can be used using

${property_name}

Ant predefined properties

Property

Description

ant.version

Version of apache ant

ant.java.version

Java version that apache ant is using

ant.home

Home directory where apache is installed

ant.library.dir

Path of ant library files

ant.file

Location of build file

basedir

Base directory of build

Echoing message on screen

<echo message="Version of Apache Ant ${ant.project.name}: ${ant.file}"/>

Define classpath

<path id="classpath">
    <fileset dir="directory_path" includes="*.jar" />
    <fileset dir="directory_path" includes="*.jar" />
</path>

Compiling Java code

<javac srcdir="source_path_of_java_files" classpathref="classpath" destdir="destination_of_compiled_files" />

Creating Jar 

<jar jarfile="jar_name.jar" basedir="compiled_files_path" includes="**/*.class" update="true">

Create directory

<mkdir dir="directory_name" />

Delete directory

<delete dir="directory_name" />

Copy directory

<copy todir="directory_path_where_to_copy" overwrite="true">
    <fileset dir="directory_path_to_copy_files">
         <include name="**/*.*" />
     </fileset>
</copy>

Copy files

<copy file="file_to_copy" todir="directory_path_where_to_copy" overwrite="true" />

Delete files

 <delete>
     <fileset dir="directory_path_to_copy_files">
         <include name="file_name_or_wild_card"/>
         <include name="file_name_or_wild_card"/>
    </fileset>
 </delete>

File loading 

<loadfile property="defined_property_name" srcFile="file_to_load_as_string" />

Replace string in file

<replace file="file_path" token="string_to_replace" value="string_value_to_replace_with"></replace>

Set property based on condition

Based on condition property value is set to true or false.

<condition property="property_name_to_set">
     <matches string="string_data" pattern="pattern_to_match_in_string" />
 </condition>

Above code will set property if particular pattern is matched in specified string. Pattern can hold regex expression. You can specified string inline or property that holds the string file data. Detailed explanation is available on official site.

If-else

<if>
   <equals arg1="value" arg2="value"/>
   <then><echo message="if block executed"/></then>
   <else>
         <echo message="else block executed"/>
   </else>
</if>

Like if-else in any other language, based on condition task is performed. Detailed explanation is available on official site.

Call target inside a target

<antcall target="valid_target_name"/>

Add external tasks

<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="./lib/xmltask.jar" />

Xmltask : Insert data using XPath

<xmltask source="source_file_to_edit" dest="destination_to_save_file">
     <insert path="//*[local-name()='beans'][1]/*[local-name()='bean'][last()]" position="after">
           <![CDATA[
              <import xmlns="http://www.springframework.org/schema/beans" resource="MyData.xml"/>
            ]]>
     </insert>
 </xmltask>
 
 Above command will insert xml-import after the path defined using XPath.

Xmltask : Insert data based on condition using XPath

<xmltask source="source_file_to_edit" dest="destination_to_save_file">
     <copy path="//*[local-name()='beans'][1]/*[local-name()='bean'][@resource='MyData.xml']/@resource" property="ITEM_EXISTS_ALREADY" />
     <insert path="//*[local-name()='beans'][1]/*[local-name()='bean'][last()]" position="after"> position="after" unless="ITEM_EXISTS_ALREADY">
         <![CDATA[
            <import xmlns="http://www.springframework.org/schema/beans" resource="MyData.xml"/>
         ]]>
      </insert>
</xmltask>

The above code will set property ITEM_EXISTS_ALREADY if the attribute resource with value MyData.xml  exists under given XPath. Then insertion will be performed based on the ITEM_EXISTS_PROPERTY.

Xmltask : Remove xml content

<xmltask source="source_file_to_edit" dest="destination_to_save_file">
    <remove path="/beans/bean/import[@resource='MyData.xml']"/>
 </xmltask> 

The above code will remove the import with resource value MyData.xml.

Reference

https://ant.apache.org/

https://www.tutorialspoint.com/ant/index.htm

en_USEnglish
en_USEnglish