Adopting Vue.js for Angular Geeks | Nitor Infotech
Send me Nitor Infotech's Monthly Blog Newsletter!
×
nitor logo
  • Company
    • About
    • Leadership
    • Partnership
  • Resource Hub
  • Blog
  • Contact
nitor logo
Add more content here...
Artificial intelligence Big Data Blockchain and IoT
Business Intelligence Careers Cloud and DevOps
Digital Transformation Healthcare IT Manufacturing
Mobility Product Modernization Software Engineering
Thought Leadership
Aastha Sinha Abhijeet Shah Abhishek Suranglikar
Abhishek Tanwade Abhishek Tiwari Ajinkya Pathak
Amit Pawade Amol Jadhav Ankita Kulkarni
Antara Datta Anup Manekar Ashish Baldota
Chandra Gosetty Chandrakiran Parkar Deep Shikha Bhat
Dr. Girish Shinde Gaurav Mishra Gaurav Rathod
Gautam Patil Harish Singh Chauhan Harshali Chandgadkar
Kapil Joshi Madhavi Pawar Marappa Reddy
Milan Pansuriya Minal Doiphode Mohit Agarwal
Mohit Borse Nalini Vijayraghavan Neha Garg
Nikhil Kulkarni Omkar Ingawale Omkar Kulkarni
Pooja Dhule Pranit Gangurde Prashant Kamble
Prashant Kankokar Priya Patole Rahul Ganorkar
Ramireddy Manohar Ravi Agrawal Robin Pandita
Rohan Chavan Rohini Wwagh Sachin Saini
Sadhana Sharma Sambid Pradhan Sandeep Mali
Sanjeev Fadnavis Saurabh Pimpalkar Sayanti Shrivastava
Shardul Gurjar Shravani Dhavale Shreyash Bhoyar
Shubham Kamble Shubham Muneshwar Shubham Navale
Shweta Chinchore Sidhant Naveria Souvik Adhikary
Sreenivasulu Reddy Sujay Hamane Tejbahadur Singh
Tushar Sangore Vasishtha Ingale Veena Metri
Vidisha Chirmulay Yogesh Kulkarni
Software Engineering | 09 Apr 2020 |   23 min

Adopting Vue.js for Angular Geeks

featured image

In last decade, Javascript framework and libraries have taken this world by strome. And they have come across a long way. AngularJS, (Knockout + Durandal + RequireJS), Angular, React, Vue etc are some of the framework which were either widely used or are currently widely used.There are many supporting libraries like loadash, _, etc supports those framework and make it a complete modern web development framework.

Even those above mentioned frameworks have come across a long way.Some were widely used before few years like for e.g. (Knockout + Durandal + RequireJS) and AngularJS. In case of AngularJS, its earliear version was entirely rewritten with major breaking changes. Angular v2.0 onwards (as compared to AngularJS v1.x) is a huge success and is widely used to create modern web application.Now the criteria of selecting either Angular or React or VUE depends on various parameters.

One such library that is widely used those days is Vue.js (Hereafter, we will refer it by its popular name Vue). So the question come is why Vue? What advantage does Vue bring when compared to Angular and React? Why should we adopt Vue? What is it learning curve? What kind of investment will be required by an organization to train their existing Angular or React resource to adopt Vue?

Briefly, Vue is a JavaScript library for building interactive web interfaces. Combining with some other development tools, it also becomes a framework. Vue provides data-reactive components with a simple and flexible API. Moreover, it is lightweight and much easier to get started with when compared to others.

Vue is created by Evan You. And as per him, VUE IS A MORE FLEXIBLE, LESS OPINIONATED SOLUTION ( THAN ANGULAR ). THAT ALLOWS YOU TO STRUCTURE YOUR APP THE WAY YOU WANT IT TO BE, INSTEAD OF BEING FORCED TO DO EVERYTHING THE ANGULAR WAY. IT’S ONLY AN INTERFACE LAYER SO YOU CAN USE IT AS A LIGHT FEATURE IN PAGES INSTEAD OF A FULL BLOWN SPA.

Our organization have a very rich experience of working with both Angular and Vue. So the purpose of writing this paper is to help you understand conceptual similarities(rather differencies) between Vue and Angular. This paper can be helpful to understand what level of efforts will be required to train Angular developer to adopt Vue and vice versa.

Command line Interface(CLI)

Command line interface(CLI) is used to speed up application development. Typically by using CLI, you don’t need to spend time installing and configuring all the required dependencies and wiring everything together.

In Angular, we have Angular CLI. You can use Angular Console in case if you are not familiar with commands and prefer UI.

Where as in Vue, we have Vue CLI. And we have Vue UI for in case if you prefer UI.

This is the first similarity in the Vue vs Angular debate.

Components

In Angular we’re setting up a Module to wrap some component(s) with @NgModule and @Component decorators, in Vue you’re using Vue.component() to register your components on the Vue instance.

Everything is based around Components, nesting them within each other, passing data between them and so on.

As a composition model, components are meant to be self-contained sections or “bits” of your application that you can then reuse in more specific contexts. The great thing they allow is a way to encapsulate logic, providing API guarantees: you pass x, y and z into this component and you will get these a, b, c behaviours out of it, anything the component does internally is its own business.

This is the another and most important similarity in the Vue vs Angular debate.

Data Passing between Components

Data passing patterns are simplified with a component-based application: the communication is done from the parent to the child as well as from child to parent.

In Angular, @Input and @Output bindings are defined in the component and bound in the template. @Input is used to pass data from parent template to Child template. And @Output is used to pass data from child template to parent template.@Output behaves like events in that they are emitted by the child and listened to by the parent.

In Vue, props are passed from parent to child and the child can emit events back to the parent for e.g.

From below parent component, we are passing data as params.

<router-link

tag=”button”

class=”link card-footer-item”

:to=”{ name: ‘patient-detail’, params: { id: hero.id } }”

>

And it is handled in child component as below

export default {

name: ‘PatientDetail’,

props: {

id: {

type: Number,

default: 0,

},

}

In and Out of ComponentsAngularVue
input property@Input()props
emit an event@Output() with EventEmitterthis.$emit

Templates, styles and tooling

Angular leans towards one folder per Module/Component where your TypeScript, template(html) and style files live. Templates and styles can be written inline in the Angular component inline but the best practice is to have separate files. This is a good idea for large single page applications.

Vue is called “the progressive framework” because it offers different features depending on the size of the application being developed. In the simplest case (Vue globally included using a CDN and script tag), writing templates inline is encouraged. Vue also offers a CLI and packages that integrate with build tools like webpack. The preferred way to write components in this environment is the single-file component a file with a template, a script and a style tag. Vue-loader compiles the template into JavaScript along with the script section and extracts the contents of the style tag into a stylesheet at build time. You have a option to use typescript as well in case if typescript is your choice over Javascript.

Lifecycle

The component lifecycles are provided under different method names in both Angular and Vue framework.

Both provide a mounted/dismount which refers to the component being initialised in the DOM and it not being needed any more. It’s also possible to listen to updates to data and props which usually trigger a re-render of the template.

Bindings

The bindings for Angular and Vue are indeed interesting. In Angular, we have a (click) binding syntax while in Vue we use @click. Here are some other similarities in the bindings, in the following table.

BindingAngularVue
click event(click)@click
enter key-up event(keyup.enter)@keyup.enter
add/remove content*ngIfv-if
model binding[(ngModel)](Two way binding)v-model(Two way binding)
String interpolation{{ }} (one way binding){{ }} (one way binding)
HTML element reference#ref

Http

In real world application, one or the other http library is used to communicate with other applications. In case of Angular and Vue, Http library is mainly used for CRUD operations using APIs.

Mostly, those libraries have the same set of methods. Angular uses RxJS by convention to communicate with HTTP while Vue uses Axios with promises by convention. That’s why we see subscribe for Angular and then for Vue in the calls to the service, for the asynchronous operations. These are just different techniques, and the code is very similar.

Custom Directive

In both Angular and Vue, the primary form of code reuse and abstraction is components – however there may be cases where you need some low-level DOM access on plain elements, and this is where custom directives would still be useful.

In Angular, we use @Directive decorator to create a new directive. For e.g.

import {Directive, ElementRef, OnInit} from ‘@angular/core’;

@Directive( {

selector: ‘[appSimpleStyle]’

})

export class SimpleStyleDirective implements OnInit {

constructor(private elementRef: ElementRef) {

}

ngOnInit() {

this.elementRef.nativeElement.style.backgroundColor = ‘green’;

}

Whereas in Vue, we use Vue.directive to create directives. For e.g.

// Register a global custom directive called `v-focus`

Vue.directive(‘focus’, {

// When the bound element is inserted into the DOM…

inserted: function (el) {

// Focus the element

el.focus()

}

})

Filter/Pipe

Pipes are useful feature in Angular. They are a simple way to transform values in an Angular template. There are some built in pipes, but you can also build your own pipes.A pipe takes in a value or values and then returns a value. This is great for simple transformations on data but it can also be used in other unique ways

@Pipe({name: ‘default’, pure: true})

export class DefaultPipe {

transform(value: any, defaultValue: any): any {

return value || defaultValue;

}

}

Similarly, Vue have filters for the exact same purpose. Vue allows you to define filters that can be used to apply common text formatting. Filters are usable in two places: mustache interpolations and v-bind expressions (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the “pipe” symbol for e.g.

filters: {

capitalize: function (value) {

if (!value) return ”

value = value.toString()

return value.charAt(0).toUpperCase() + value.slice(1)

}

}

Routing

In a single-page application, to navigate from one view to another, a routing system needs to be set up.

Angular provides its own routing module; so does Vue, though it requires an additional installation

Angular’s and Vue’s routes are configured as part of initialization of the app; it happens before any of the components are rendered. In Angular and Vue, the code pertaining to the router module and the routes don’t intermingle with that of components. To display the active view, Angular and Vue use a placeholder directive (router-outlet and router-view, respectively).

Both Angular and Vue supports lazy loading through routing.

State Management

State Management is Must Have for any Enterprise application. But what is application state? Theoretically, it is the entire memory of the application, but, typically, it is the data received via API calls, user inputs, presentation UI State, app preferences, etc. Simply put, it is the data that can differentiate two instances of the same application. A simple concrete example of application state would be a list of customers maintained in an application.

In case of Angular,NgRx is widely used for state management. It is inspired from Redux which is a framework agnostic state management library.

Whereas in Vue, VUEX is a default state management technique.

DOM Rendering

Till now, we have only covered similarities between Angular and VUE. However, it is important to cover major difference i.e. DOM Rendering. VUE uses virtual DOM (Similar to React) as compared to DOM being used by Angular. So Question arises is what is Virtual DOM and how is it different from DOM? What are its advantages?

Few years ago, React captured the excitement of developer community by streamlining idea of a virtual DOM. It is React from which Vue 2.0 onwards have adopted the idea of Virtual DOM. It is from Virtual DOM from which React and VUE derives better performance.

The Virtual DOM is an abstraction of the HTML DOM. It is lightweight and detached from the browser-specific implementation details. Since the DOM itself was already an abstraction, the virtual DOM is, in fact, an abstraction of an abstraction. Perhaps it’s better to think of the virtual DOM as VUE’s local and simplified copy of the HTML DOM. It allows VUE to do its computations within this abstract world and skip the “real” DOM operations, which are often slow and browser-specific This slowness is made worse by the fact that most JavaScript frameworks update the DOM much more than it is really required.

 How Virtual DOM Helps? 

Pic Reference – http://teropa.info/blog/2015/03/02/change-and-its-detection-in-javascript-frameworks.html

As mentioned earliear, Manipulating the DOM is slow. But manipulating the virtual DOM is much faster, because nothing gets drawn onscreen. Technically, when virtual DOM updates, then VUE compares the virtual DOM with a virtual DOM snapshot that was taken right before the update. By comparing the new virtual DOM with a pre-update version, VUE figures out exactly which virtual DOM objects have changed. This process is called “diffing.” Once VUE knows which virtual DOM objects have changed, then VUE updates only those objects on the real DOM.

This makes a big difference as only updated parts of DOM are redrawn. Also, same principle applies when you navigate from one page to another page. SO lets say if you have common sections across pages, DOM will not update and redraw it unless there is some update.

So how quickly will Angular developer be able to adopt VUE’s virtual DOM? According to our experience, it will be a very straight forward adoption with all HTML portion of code in .vue files being written between

<template>

</template>

Whereas, in our experience developers (Non React developers working on React for first time) found it little difficult to adopt React Virtual DOM i.e. JSX as compared to VUE’s Virtual DOM.

Nitor Infotech’s experience of using Vue

At Nitor Infotech, Vue have helped us in following ways.

  1. It is globally proven that Vue is good for prototyping. And Nitor Infotech have experienced it. Vue have helped us to create prototype faster and this in turn have helped our customer to reduce their go to market time.
  2. In many cases, we were able to integrate and use Vue with legacy application without introducing any breaking changes in legacy architecture.
  3. Point 2 above have proved to be successfull begining of modernization journey for many of our customers.
  4. And our developers found Vue to be more simpler as compared to Angular or React. Our overall experience says that it took us around 40% to 50% less time to train a Vue developer as compared to Angular or React developer.

Conclusion

We have tried to list out similarities of both Angular and Vue in above discussed points. Conceptually, there is 65 to 70% similarity between Angular and Vue.

Also, in many cases, we found Vue to be more simpler and cleaner as compared to Angular.So we very confidently assert that an Angular developer can very easily adopt Vue with a minimal learning curve.

Related Topics

Artificial intelligence

Big Data

Blockchain and IoT

Business Intelligence

Careers

Cloud and DevOps

Digital Transformation

Healthcare IT

Manufacturing

Mobility

Product Modernization

Software Engineering

Thought Leadership

<< Previous Blog fav Next Blog >>
author image

Nitor Infotech Blog

Nitor Infotech is a leading software product development firm serving ISVs and enterprise customers globally.

   

You may also like

featured image

10 Heuristic Principles in UX Engineering

Say, you’ve built a modern, cutting-edge application. It has a complex, multi-layered user interface (UI), that is the basis for some amazing features. Since you’re the one who has built the applic...
Read Blog


featured image

ETL Testing: A Detailed Guide

Just in case the term is new to you, ETL is defined from data warehousing and stands for Extract-Transform-Load. It covers the process of how the data is loaded from the multiple source system to t...
Read Blog


featured image

Getting Started with ArcGIS Online

GeoServer is an open-source server that facilitates the sharing, processing and editing of geospatial data. When we are dealing with a large set of geospatial d...
Read Blog


subscribe

Subscribe to our fortnightly newsletter!

We'll keep you in the loop with everything that's trending in the tech world.

Services

    Modern Software Engineering


  • Idea to MVP
  • Quality Engineering
  • Product Engineering
  • Product Modernization
  • Reliability Engineering
  • Product Maintenance

    Enterprise Solution Engineering


  • Idea to MVP
  • Strategy & Consulting
  • Enterprise Architecture & Digital Platforms
  • Solution Engineering
  • Enterprise Cognition Engineering

    Digital Experience Engineering


  • UX Engineering
  • Content Engineering
  • Peer Product Management
  • RaaS
  • Mobility Engineering

    Technology Engineering


  • Cloud Engineering
  • Cognitive Engineering
  • Blockchain Engineering
  • Data Engineering
  • IoT Engineering

    Industries


  • Healthcare
  • Retail
  • Manufacturing
  • BFSI
  • Supply Chain

    Company


  • About
  • Leadership
  • Partnership
  • Contact Us

    Resource Hub


  • White papers
  • Brochures
  • Case studies
  • Datasheet

    Explore More


  • Blog
  • Career
  • Events
  • Press Releases
  • QnA

About


With more than 16 years of experience in handling multiple technology projects across industries, Nitor Infotech has gained strong expertise in areas of technology consulting, solutioning, and product engineering. With a team of 700+ technology experts, we help leading ISVs and Enterprises with modern-day products and top-notch services through our tech-driven approach. Digitization being our key strategy, we digitally assess their operational capabilities in order to achieve our customer's end- goals.

Get in Touch


  • +1 (224) 265-7110
  • marketing@nitorinfotech.com

We are Social 24/7


© 2023 Nitor Infotech All rights reserved

  • Terms of Usage
  • Privacy Policy
  • Cookie Policy
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Accept Cookie policy