Search

Advantages and Disadvantages of Angular

What is Angular? Angular is a frontend web application development framework based on TypeScript, built by folks at Google and heavily contributed to by a huge community of developers around the world. It is a Single Page Application (SPA) framework, which means that Angular is capable and is primarily used to build single page web applications or SPAs.Angular logoAngular is developed by the same team of individuals that developed the popular framework AngularJS. The modern Angular requires you to have knowledge of the Typescript language which is a strict syntactical superset of JavaScript and adds optional static typing and some other features to the language that otherwise JavaScript lacks. The AngularJS framework was re-written and called "Angular 2", but this led to a lot of confusion and panicwithin the developer community. To clarify, the Angular team started to use separate terms for each framework. At this point, "AngularJS" now referred to the 1.X versions and "Angular" without the "JS" referred to versions 2 and up. Since then, all the versions of the framework other than 1.X are just called Angular. You can, however, mention the version number to be more precise. TypeScript is designed for development of large applications and transpiles to JavaScript. As TypeScript is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs. So, you can still use JavaScript in your TypeScript code files, but please do not do that. In this article, we will take a closer look at how Angular has evolved into one the mostpopular web development frameworks and understand its pros, cons, features and more. We will leave you with a few quick tips and suggest how you can get started with understanding Angular indepth to achieve mastery over the subject. History of Angular AngularJS was the first version of the framework, created by Google, that first came out in 2010and it shook the developer community. There were so many amazing features that AngularJS offered. Most talked and loved of all the features that it offered was two-way binding between the view and the model.  So, it let us developers get rid of a lot of useless code to set up bindings and keep the view and model in sync at all times. AngularJS was golden. AngularJS became very popular within the developer community and was widely adopted.It received a lot of traction. Still, the team decided to take another step further and developed a new version which was initially named Angular 2 but later was called Angular without the “JS” part. Soon after, in 2014, Angular 2.0 was announced which was a complete rewrite of the framework from scratch and unlike AngularJS that used JavaScript as the primary language, it used TypeScript. A final version of the framework, Angular 2, was released in 2016. Later, it was renamed to Angular to avoid conflicts and confusions within the developer community.  A lot of new changes were brought in and developers had to learn it all over again which was a tough change but was welcomed by the community. Angular opted for semantic versioning and from now on, all versions of Angular will just be called Angular. Near the end of 2016, Angular 4 came out (yeah, they skipped Angular 3 to avoid some conflicts and confusions). With a few more major versions and performance upgrades in each version, we have now arrived (at the time of writing of this article) to Angular 9.  Angular 9 has better than ever performance and latest features. In these intermediate versions, there have been updates to the performance, CLI features, progressive-web app features, router, and a lot more. They even upgraded to a better rendering engine in Angular 9. Angular 10, a major upgrade to the popular web development framework, has reached the release candidate stage, with six release candidates published as of June 17, 2020. The upgrade to the Google-developed, TypeScript-based framework focuses more on ecosystem improvements than new features. Advantages of Angular Angular hascome a long way since 2012. There are benefits to using the framework and there are some drawbacks as well, especially if you are a beginner. Let us talk about the good things first. Maintained by Google The best things about Angular is that it is developed and maintained by Google. As it is backed by a trusted company, trust is well established within the community. Developers believe in the framework and in the fact that it will be maintained, and issues will be resolved, of course withthe help of community contributions. Large community and ecosystem Angular is actively maintained and has a large community and ecosystem. You can find lots of material on this framework as well as many useful third-party tools. Currently, Angular has around over 63K stars on GitHub, a clear indication of the popularity of the framework. Github   Two-way Data binding Two-way data binding in Angular will help users to exchange data from the component to view and from view to the component. It will help users to establish communication bi-directionally. Two-way data binding can be achieved using a ngModel directive in Angular. This ensures that the model and the view are always kept in sync without any extra effort. Use of TypeScript Angular opted for TypeScript as the primary programming language. TypeScript adds a lot of syntactic sugar to JavaScript. With TypeScript, we also get several productivity benefits. In editors like VS Code and WebStorm, we have access to robust code help (intellisense) as we type, making it easier to discover types, the features they offer, and most importantly the common syntactical errors.TypeScript is a typed superset of JavaScript that compiles to plain JavaScriptSupport for i18n Internationalization is the process of making sure that an application is designed and prepared to be used in regions with different languages. Localization is the process of translating your internationalized app into specific languages for particular locales. Angular can take care of most things when it comes to multiple languages. Dates, numbers, times, and other things are easily taken care of based on the locale. On top of that, the Angular CLI allows us to install the @angular/localize package and generate most of the boilerplate code necessary. Support for lazy loading An Angular module is a logical unit of code that performs a certain task or takes care of a certain responsibility in the application. A normal Angular application can be broken down into multiple modules, where each module is delegated a certain responsibility. A module can comprise of components, pipes, directives or more modules.  Breaking down an application into modules not only allows to easily manage an application as it grows, but also offers huge performance advantages. Instead of loading all the application code at once in the browser which may cause more loading time and a slower initial render of the web page, it loads only what is necessary. This is called lazy loading.  Only the modules that are required are loaded initially and more modules or rather chunks of code are loaded as an when required. This offers seamless performance and smaller loading times. Every Angular app has at least one NgModule class, the root module which is responsible to bootstrap the project. Conventionally, it is named AppModule and itresides in a file named app.module.ts.  Dependency injection Dependency injection or DI is one of the most important application design patterns and Angular has its own dependency injection framework. It is typically used in the design of Angular applications to increase their efficiency and modularity. This is closely related to the previous point - modularization of the Angular app.   Dependencies are services or objects that a class needs to perform its function. The class requests services from an external resource, generally another module or class in this case, instead of creating them themselves. This allows us to delegate single responsibility to each module. The advantage of dependency injection design pattern is to divide the task into multiple services. The class will not create the dependent object itself, rather it will be created and injected by an Angular injector. Dependency Injection is technique that is used to reduce the coupling amongst various components of an application. Looser coupling allows for better testability and maintainability. Powerful Router Routing or in-app navigation in Angular is taken care of by the Angular Router. It is a module available in the @angular/router package. Angular router is a very powerful and flexible navigational service. It usesa component called router-outlet to load various components into the view depending upon the URL in the browser.  Angular Router has built-in support for lazy loading components, so the modules are loaded from the server as the user navigates within the app. Huge apps have a lot of benefits because of this feature.  Support for Ionic Angular was the first framework that was supported by the Ionic framework. It allows building cross-platform mobile applications for Android and iOS using the Ionic components and Angular code. As of now, more frameworks like ReactJS and VueJS are also supported but still, Angular is widely used with the Ionic framework for mobile application development.Angular is widely used with the Ionic framework for mobile app developmentAvailability of packages There is a huge repository of open-source packages available for Angular developers. Some of the most important packages are NgBootstrap, Angular Google Maps, NgRx, NgTranslate, AngularFire, NgxTextEditor, Angular Material, Ng2 Pdf Viewer, NgxCharts, and many more. Some of these packages are maintained by the official Angular team and most of these are taken care of by the community of developers as well. It is most likely that if you are looking to build a complex feature or a component for your application, a package already exists for you, so why reinvent the wheel? Disadvantages of Angular So, we have seen the good things about Angular, but there is another side to the story as well. Let us talk about some of the downsides of using one of the most popular web development framework. Steeper learning curve While Angular is great, it may not be the case for a complete beginner. Even if you have experience with HTML, CSS and JS, you may feel a little bit uncomfortable with the steep learning curve that it has. It brings its own notions and philosophy to the table that you need to work around.  Angular is an opinionated framework which means that it has its own rules that developers need to learn and follow. This can be a good and a bad thing, but the learning curve can be uncomfortable for total beginners. I would recommend that you stay patient and start slow. Slow and steady! Limited SEO Capabilities Angular is just great for building powerful single-page web applications. However, as with all single-page web applications, there is a disadvantage when it comes to search engine optimization.   Usually single-page applications are rendered on the client side and therefore web crawlers of search engines like Google and Bing are not able to see the complete structure and content of the individual pages of the websites. With this limitation in place,it is not possible to list your website correctly in search engine results.  However, there are techniques and packages to make this work, but it is an extra effort in terms of development. Angular universal is a way to render the Angular application of the server itself. The technology enables server-side rendering for Angular applications. Angular Universal generates static application pages on the server through a process called server-side rendering. While Angular universal takes care of most aspects, it still requires a lot of setup. If you prefer to do it all manually, there are documents available to help you do that but there are gotchas that you need to watch out for. Too many versions Angular has been evolving. It started out as a JavaScript framework AngularJS and now the current version is Angular 9 with a total of 6 major releases in between. This can cause confusion especially for beginners. Many a time, beginners struggle to understand the versioning. I have seen students learning a version of the framework, latest at the time, and by the time they finish their first project, a new major release is out. This causes trust issues. Developers, at times, feel that they must keep working on their apps and resolve version conflicts and compatibility issues. Decline in popularity With the advent of newer frameworks like VueJS and ReactJS, Angular has seen a downfall in its popularity. Just a few years ago, developers were mainly debating on whether they should be using Angular or React for their projects. But over the course of the last couple of years, we saw a growth of interest in a third player called VueJS or Vue.js. While the job market in Angular continues to expand, it has been observed that the popularity of the framework has been declining. I believe that too many versions is one of the main issues that the framework needs to address. Lot of boilerplate code If you are building a simple app, there is a lot of boilerplate code that the application requires. Although with tools like StackBlitz, it has become easier to try code ideas and experiment without having to install anything on your computer, but if you decide to start developing an Angular app on your system, you need to install a bunch of things and the most simple “Hello World!” application will have a lot of code that you do not care about. What’s new in Angular 9? Let us take a closer look at what is in store for us in the Angular 9 version of the framework. We will delve into the latest version of Angular 10, released in June 2020, in a separate blog post. Step-by-step guide The official Angular website offers a step-by-step guide on how to upgrade your existing apps to the latest version. GuideIvy, the next-gen compilation and rendering engine Ivy is the code name for Angular's next-generation compilation and rendering engine. With the version 9 release of Angular, the new compiler and runtime instructions are used by default instead of the older compiler and runtime, known as View Engine. You can, however, disable Ivy if you still want to use View Engine for your app. It is a huge milestone for the framework. Ivy offers faster build times and small build sizes. It also offers a new change detection system.The important point is that we don’t have to change how we write our applications. Ivy aims to be compatible with the existing applications. Ivy is going to be smaller, simpler, and faster as quoted by the Angular team.  In the demo shown by Miško Hevery, the creator of the AngularJS framework,in ngConf 2018, the Hello World application was merely 3.2KB which is significantly small although 3.2KB is the result after minification + gzip.Total bundle SizeIvy compiles one file at a time and therefore follows the locality principle. Ivy looks at a component's template when generating the compiled output. This process leads to faster compilation. Ivy makes sure that, if you are not using something in Angular, it does not get included. Since Ivy pipelining is simplified, templates will be part of the stack trace.  No more cryptic error messages when something is broken in our template syntax as we will see the exact line number where the error is. The Ivy compiler has been designed to remove parts of Angular code that aren’t being used via a mechanism called tree-shaking and to generate less code for each Angular component. With these improvements, small apps and large apps can see the most dramatic size savings. Angular ahead-of-time (AOT)  In Angular 9, AOT is enabled for Dev build as well. The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code.  Compiling your application during the build process provides a faster rendering in the browser. AOT allows faster rendering of the application and also makes sure that there are a lot less asynchronous requests. According to the docs, AOT compilation with Ivy is faster and should be used by default. Lazy loading components Before Angular 9, we could only lazy load modules. Now, you can also lazy load components. It is a great way to shrink the size of your main bundle and boost the initial load of your application. Lazy loading of single components has not been possible so far. But things have changed with Ivy.  Works with TypeScript 3.6 and 3.7 The latest version of the TypeScript is 3.7 and Angular 9 is updated to work with TypeScript 3.6 and 3.7. Angular 9 supports usage of the same TypeScript Diagnostics format for the TypeScript Compiler diagnostics, which will generate more descriptive error messages. According to the official docs - “In TypeScript 3.7, when opening a project with dependencies, TypeScript will automatically use the source . ts / . tsx files instead. This means projects using project references will now see an improved editing experience where semantic operations are up-to-date and “just work”. SupportscCSS variables or custom properties Angular 9 supports CSS variables or custom properties. CSS variables or custom properties allowsdevelopers to define their own variables for CSS values that can be shared between components and style rules.  CSS custom properties or CSS variables allow the CSS property values to be changed at runtime. The possibility that the CSS custom properties can be updated during runtimeopens the opportunity to easily create themes for newer Angular application.  Angular:Quick tips and facts Angular is a framework used for front-end development. This involves the client-side of the application and has little to do with the back end. Angular is best utilized for completing advanced, large-scale projects under the direction of a seasoned developer. Angular is created for enterprise-scale applications. Angular elements can be added to projects that were built using a different platform, such as React or Polymer. Angular is supported by Google. This program is not up to par with SEO best practices, so if your primary focus is search engine optimization, opt for a different platform. Angular is a JavaScript framework—not a JS Library.Angular ranked second in “most used technology” in the Stack Overflow Survey of 2018.  How to get started with Angular?Are you ready to take on the best and become a master of the Angular framework? Check out the Angular Training and Certification which comes with instructor-led live training and real-life project experience.  This training will help you understand Angular in-depth and help you achieve mastery over the subject. Master Angular programming with our in-depth online courses. Explore them now!

Advantages and Disadvantages of Angular

13K
Advantages and Disadvantages of Angular

What is Angular? 

Angular is a frontend web application development framework based on TypeScript, built by folks at Google and heavily contributed to by a huge community of developers around the world. It is a Single Page Application (SPA) framework, which means that Angular is capable and is primarily used to build single page web applications or SPAs.

Angular logoAngular logo

Angular is developed by the same team of individuals that developed the popular framework AngularJS. The modern Angular requires you to have knowledge of the Typescript language which is a strict syntactical superset of JavaScript and adds optional static typing and some other features to the language that otherwise JavaScript lacks. 

The AngularJS framework was re-written and called "Angular 2", but this led to a lot of confusion and panicwithin the developer community. To clarify, the Angular team started to use separate terms for each framework. At this point, "AngularJS" now referred to the 1.X versions and "Angular" without the "JS" referred to versions 2 and up. Since then, all the versions of the framework other than 1.X are just called Angular. You can, however, mention the version number to be more precise. 

TypeScript is designed for development of large applications and transpiles to JavaScript. As TypeScript is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs. So, you can still use JavaScript in your TypeScript code files, but please do not do that. 

In this article, we will take a closer look at how Angular has evolved into one the mostpopular web development frameworks and understand its pros, cons, features and more. We will leave you with a few quick tips and suggest how you can get started with understanding Angular indepth to achieve mastery over the subject. 

History of Angular 

AngularJS was the first version of the framework, created by Google, that first came out in 2010and it shook the developer community. There were so many amazing features that AngularJS offered. Most talked and loved of all the features that it offered was two-way binding between the view and the model.  

So, it let us developers get rid of a lot of useless code to set up bindings and keep the view and model in sync at all times. AngularJS was golden. AngularJS became very popular within the developer community and was widely adopted.It received a lot of traction. Still, the team decided to take another step further and developed a new version which was initially named Angular 2 but later was called Angular without the “JS” part. 

Soon after, in 2014, Angular 2.0 was announced which was a complete rewrite of the framework from scratch and unlike AngularJS that used JavaScript as the primary language, it used TypeScript. A final version of the framework, Angular 2, was released in 2016. Later, it was renamed to Angular to avoid conflicts and confusions within the developer community.  

A lot of new changes were brought in and developers had to learn it all over again which was a tough change but was welcomed by the community. Angular opted for semantic versioning and from now on, all versions of Angular will just be called Angular. 

Near the end of 2016, Angular 4 came out (yeah, they skipped Angular 3 to avoid some conflicts and confusions). With a few more major versions and performance upgrades in each version, we have now arrived (at the time of writing of this article) to Angular 9.  

Angular 9 has better than ever performance and latest features. In these intermediate versions, there have been updates to the performance, CLI features, progressive-web app features, router, and a lot more. They even upgraded to a better rendering engine in Angular 9. 

Angular 10, a major upgrade to the popular web development framework, has reached the release candidate stage, with six release candidates published as of June 17, 2020. The upgrade to the Google-developed, TypeScript-based framework focuses more on ecosystem improvements than new features. 

Advantages of Angular 

Angular hascome a long way since 2012. There are benefits to using the framework and there are some drawbacks as well, especially if you are a beginner. Let us talk about the good things first. 

Maintained by Google 

The best things about Angular is that it is developed and maintained by Google. As it is backed by a trusted company, trust is well established within the community. Developers believe in the framework and in the fact that it will be maintained, and issues will be resolved, of course withthe help of community contributions. 

Large community and ecosystem 

Angular is actively maintained and has a large community and ecosystem. You can find lots of material on this framework as well as many useful third-party tools. Currently, Angular has around over 63K stars on GitHub, a clear indication of the popularity of the framework. 

Angular is one of the most popular frameworks

Github   

Two-way Data binding 

Two-way data binding in Angular will help users to exchange data from the component to view and from view to the component. It will help users to establish communication bi-directionally. Two-way data binding can be achieved using a ngModel directive in Angular. This ensures that the model and the view are always kept in sync without any extra effort. 

Use of TypeScript 

Angular opted for TypeScript as the primary programming language. TypeScript adds a lot of syntactic sugar to JavaScript. With TypeScript, we also get several productivity benefits. In editors like VS Code and WebStorm, we have access to robust code help (intellisense) as we type, making it easier to discover types, the features they offer, and most importantly the common syntactical errors.

TypeScript is a typed superset of JavaScript that compiles to plain JavaScriptTypeScript is a typed superset of JavaScript that compiles to plain JavaScript

Support for i18n 

Internationalization is the process of making sure that an application is designed and prepared to be used in regions with different languages. Localization is the process of translating your internationalized app into specific languages for particular locales. Angular can take care of most things when it comes to multiple languages. Dates, numbers, times, and other things are easily taken care of based on the locale. On top of that, the Angular CLI allows us to install the @angular/localize package and generate most of the boilerplate code necessary. 

Support for lazy loading 

An Angular module is a logical unit of code that performs a certain task or takes care of a certain responsibility in the application. A normal Angular application can be broken down into multiple modules, where each module is delegated a certain responsibility. A module can comprise of components, pipes, directives or more modules.  

Breaking down an application into modules not only allows to easily manage an application as it grows, but also offers huge performance advantages. Instead of loading all the application code at once in the browser which may cause more loading time and a slower initial render of the web page, it loads only what is necessary. This is called lazy loading.  

Only the modules that are required are loaded initially and more modules or rather chunks of code are loaded as an when required. This offers seamless performance and smaller loading times.
 
Every Angular app has at least one NgModule class, the root module which is responsible to bootstrap the project. Conventionally, it is named AppModule and itresides in a file named app.module.ts.  

Dependency injection 

Dependency injection or DI is one of the most important application design patterns and Angular has its own dependency injection framework. It is typically used in the design of Angular applications to increase their efficiency and modularity. This is closely related to the previous point - modularization of the Angular app.  
 
Dependencies are services or objects that a class needs to perform its function. The class requests services from an external resource, generally another module or class in this case, instead of creating them themselves. This allows us to delegate single responsibility to each module.
 
The advantage of dependency injection design pattern is to divide the task into multiple services. The class will not create the dependent object itself, rather it will be created and injected by an Angular injector. Dependency Injection is technique that is used to reduce the coupling amongst various components of an application. Looser coupling allows for better testability and maintainability. 

Powerful Router 

Routing or in-app navigation in Angular is taken care of by the Angular Router. It is a module available in the @angular/router package. Angular router is a very powerful and flexible navigational service. It usesa component called router-outlet to load various components into the view depending upon the URL in the browser.  

Angular Router has built-in support for lazy loading components, so the modules are loaded from the server as the user navigates within the app. Huge apps have a lot of benefits because of this feature.  

Support for Ionic 

Angular was the first framework that was supported by the Ionic framework. It allows building cross-platform mobile applications for Android and iOS using the Ionic components and Angular code. As of now, more frameworks like ReactJS and VueJS are also supported but still, Angular is widely used with the Ionic framework for mobile application development.

Angular is widely used with the Ionic framework for mobile app developmentAngular is widely used with the Ionic framework for mobile app development

Availability of packages 

There is a huge repository of open-source packages available for Angular developers. Some of the most important packages are NgBootstrap, Angular Google Maps, NgRx, NgTranslate, AngularFire, NgxTextEditor, Angular Material, Ng2 Pdf Viewer, NgxCharts, and many more. Some of these packages are maintained by the official Angular team and most of these are taken care of by the community of developers as well. It is most likely that if you are looking to build a complex feature or a component for your application, a package already exists for you, so why reinvent the wheel? 

Disadvantages of Angular 

So, we have seen the good things about Angular, but there is another side to the story as well. Let us talk about some of the downsides of using one of the most popular web development framework. 

Steeper learning curve 

While Angular is great, it may not be the case for a complete beginner. Even if you have experience with HTML, CSS and JS, you may feel a little bit uncomfortable with the steep learning curve that it has. It brings its own notions and philosophy to the table that you need to work around.  

Angular is an opinionated framework which means that it has its own rules that developers need to learn and follow. This can be a good and a bad thing, but the learning curve can be uncomfortable for total beginners. I would recommend that you stay patient and start slow. Slow and steady! 

Limited SEO Capabilities 

Angular is just great for building powerful single-page web applications. However, as with all single-page web applications, there is a disadvantage when it comes to search engine optimization.  
 
Usually single-page applications are rendered on the client side and therefore web crawlers of search engines like Google and Bing are not able to see the complete structure and content of the individual pages of the websites. With this limitation in place,it is not possible to list your website correctly in search engine results.  

However, there are techniques and packages to make this work, but it is an extra effort in terms of development. Angular universal is a way to render the Angular application of the server itself. The technology enables server-side rendering for Angular applications. Angular Universal generates static application pages on the server through a process called server-side rendering. 

While Angular universal takes care of most aspects, it still requires a lot of setup. If you prefer to do it all manually, there are documents available to help you do that but there are gotchas that you need to watch out for. 

Too many versions 

Angular has been evolving. It started out as a JavaScript framework AngularJS and now the current version is Angular 9 with a total of 6 major releases in between. This can cause confusion especially for beginners. 

Many a time, beginners struggle to understand the versioning. I have seen students learning a version of the framework, latest at the time, and by the time they finish their first project, a new major release is out. This causes trust issues. Developers, at times, feel that they must keep working on their apps and resolve version conflicts and compatibility issues. 

Decline in popularity 

With the advent of newer frameworks like VueJS and ReactJS, Angular has seen a downfall in its popularity. Just a few years ago, developers were mainly debating on whether they should be using Angular or React for their projects. But over the course of the last couple of years, we saw a growth of interest in a third player called VueJS or Vue.js.
 
While the job market in Angular continues to expand, it has been observed that the popularity of the framework has been declining. I believe that too many versions is one of the main issues that the framework needs to address. 

Lot of boilerplate code 

If you are building a simple app, there is a lot of boilerplate code that the application requires. Although with tools like StackBlitz, it has become easier to try code ideas and experiment without having to install anything on your computer, but if you decide to start developing an Angular app on your system, you need to install a bunch of things and the most simple “Hello World!” application will have a lot of code that you do not care about. 

What’s new in Angular 9? 

Let us take a closer look at what is in store for us in the Angular 9 version of the framework. We will delve into the latest version of Angular 10, released in June 2020, in a separate blog post. 

Step-by-step guide 

The official Angular website offers a step-by-step guide on how to upgrade your existing apps to the latest version. 

Step-by-step guide

Guide

Ivy, the next-gen compilation and rendering engine 

Ivy is the code name for Angular's next-generation compilation and rendering engine. With the version 9 release of Angular, the new compiler and runtime instructions are used by default instead of the older compiler and runtime, known as View Engine. You can, however, disable Ivy if you still want to use View Engine for your app. It is a huge milestone for the framework. Ivy offers faster build times and small build sizes. It also offers a new change detection system.

The important point is that we don’t have to change how we write our applications. Ivy aims to be compatible with the existing applications. Ivy is going to be smaller, simpler, and faster as quoted by the Angular team.  

In the demo shown by Miško Hevery, the creator of the AngularJS framework,in ngConf 2018, the Hello World application was merely 3.2KB which is significantly small although 3.2KB is the result after minification + gzip.

Total bundle SizeTotal bundle Size

Ivy compiles one file at a time and therefore follows the locality principle. Ivy looks at a component's template when generating the compiled output. This process leads to faster compilation. Ivy makes sure that, if you are not using something in Angular, it does not get included. Since Ivy pipelining is simplified, templates will be part of the stack trace.  

No more cryptic error messages when something is broken in our template syntax as we will see the exact line number where the error is. 

The Ivy compiler has been designed to remove parts of Angular code that aren’t being used via a mechanism called tree-shaking and to generate less code for each Angular component. With these improvements, small apps and large apps can see the most dramatic size savings. 

Angular ahead-of-time (AOT)  

In Angular 9, AOT is enabled for Dev build as well. The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code.  

Compiling your application during the build process provides a faster rendering in the browser. AOT allows faster rendering of the application and also makes sure that there are a lot less asynchronous requests. According to the docs, AOT compilation with Ivy is faster and should be used by default. 

Lazy loading components 

Before Angular 9, we could only lazy load modules. Now, you can also lazy load components. It is a great way to shrink the size of your main bundle and boost the initial load of your application. Lazy loading of single components has not been possible so far. But things have changed with Ivy.  

Works with TypeScript 3.6 and 3.7 

The latest version of the TypeScript is 3.7 and Angular 9 is updated to work with TypeScript 3.6 and 3.7. Angular 9 supports usage of the same TypeScript Diagnostics format for the TypeScript Compiler diagnostics, which will generate more descriptive error messages. 

According to the official docs - “In TypeScript 3.7, when opening a project with dependencies, TypeScript will automatically use the source . ts / . tsx files instead. This means projects using project references will now see an improved editing experience where semantic operations are up-to-date and “just work”. 

SupportscCSS variables or custom properties 

Angular 9 supports CSS variables or custom properties. CSS variables or custom properties allowsdevelopers to define their own variables for CSS values that can be shared between components and style rules.  

CSS custom properties or CSS variables allow the CSS property values to be changed at runtime. The possibility that the CSS custom properties can be updated during runtimeopens the opportunity to easily create themes for newer Angular application.  

Angular:Quick tips and facts 

Angular is a framework used for front-end development. This involves the client-side of the application and has little to do with the back end. 

  1. Angular is best utilized for completing advanced, large-scale projects under the direction of a seasoned developer. 
  2. Angular is created for enterprise-scale applications. 
  3. Angular elements can be added to projects that were built using a different platform, such as React or Polymer. 
  4. Angular is supported by Google. 
  5. This program is not up to par with SEO best practices, so if your primary focus is search engine optimization, opt for a different platform. 
  6. Angular is a JavaScript framework—not a JS Library.
  7. Angular ranked second in “most used technology” in the Stack Overflow Survey of 2018.  

How to get started with Angular?

Are you ready to take on the best and become a master of the Angular framework? Check out the Angular Training and Certification which comes with instructor-led live training and real-life project experience.  

This training will help you understand Angular in-depth and help you achieve mastery over the subject. 

Master Angular programming with our in-depth online courses. Explore them now!

KnowledgeHut

KnowledgeHut

Author

KnowledgeHut is an outcome-focused global ed-tech company. We help organizations and professionals unlock excellence through skills development. We offer training solutions under the people and process, data science, full-stack development, cybersecurity, future technologies and digital transformation verticals.
Website : https://www.knowledgehut.com

Join the Discussion

Your email address will not be published. Required fields are marked *

Suggested Blogs

How To Install and Setup React Native on Mac

React Native Development Environment Installation:With the rapid growth of online websites, businesses, and the general ecosystem, it is crucial that website UIs load quickly on smartphones to encourage smartphone-based internet consumption. Facebook developed React Native from a need to generate UI elements efficiently, which formed the basis for creating the open-source web framework. Its native cross-platform capabilities allow usage for a wide range of platforms for application development, including Android, Web, Windows, UWP, tvOS, macOS, iOS, and AndroidTV. Microsoft also released a preview release in May 2020 that expanded the range of the React Native world, allowing desktop app development. React Native runs in the background of the destination device, and then communicates with the native platform via a batched asynchronous bridge. Its three main advantages are:It allows faster development due to its native natureThough it has a syntax styling similar to CSS or HTML, it is much quicker and efficientIt is flexible as it allows developers to write native code in various languages, including Java, Kotlin, and Swift.This article is about how to install and configure React Native CLI environment. First, we will learn how to install the framework, then check whether it works well and finally develop an app.PrerequisitesBasic computer proficiencyAn account with Administrative privileges on your computerAccess to the outlined documents and softwareA working internet connection to download the installation filesAudienceThis article guides first-time React Native users, junior developers, and developers with no experience with React Native. If curiosity nudged you to learn the framework due to the hype around React, then this is the guide you need.System requirementsSoftwareXcode version 11.3.1 or newer is required. Nodejs version 12 LTS or newer is required.HardwareMacOS requires a Mac device to operateRam - 4GBStorage - 10GBThese requirements ensure your tools run quickly and have enough storage for installation and development.System RequirementsReact Native requires macOS High Sierra (10.13) or higher to run efficiently.Installation through HomeBrew:HomeBrew is a package manager that helps you install and manage packages on Mac, and thus it will be essential to our installation process. You will install HomeBrew so that you can use it to install all the other tools necessary for React Native environment, including Nodejs, git, Watchman, and JDK.First download HomeBrew using the above link, then execute the command below in the Command Line Interface:brew—versionThe command verifies whether HomeBrew has been successfully installed and outputs the specific version installed as the following result shows:homebrew 2.1.7 homebrew/homebrew-core (git revision f487; last commit 2020-05-26)When the version is unavailable, you can install HomeBrew via this code:/usr/bin/ruby -e “$(curl –fsSL https://raw.githubusercontent.com/HomeBrew/install/master/install)”After installation, check whether HomeBrew has installed properly using the following command:brew--versionIf the software is well installed, the result will show the version and date as shown:homebrew 2.1.7 homebrew/homebrew-core(git revision f487; last commit 2020-05-26)NodejsReact Native is a JavaScript platform; hence it needs Nodejs to provide a JavaScript runtime.  Nodejs also provides essential tools such as a local webserver with live reloading, network tools, command-line tools, and web APIs.Use the HomeBrew command below to install Nodejs:brew install nodeCheck whether the installation is successful through the following command:node—versionIf the installation has occurred successfully, the Nodejs version will show up:V12.6.0Installation of Nodejs also includes installation of npm, the Node Package Manager. It would help if you had npm to help you install packages, libraries, and vital tools for your React development environment. To verify if npm is successfully installed, execute the following command:npm—versionIf the installation is successful, you will see the version as shown below:6.9.0WatchmanWatchman monitors the files and folders utilized by the framework and triggers specific actions if the files are modified. It would be best if you had Watchman for React Native to monitor source codes and rebuild them once they are changed.To install Watchman, execute the command below:brew install watchmanVerify installation through:watchman --versionif properly installed, the result will show the version as shown below:4.9.0React Native CLIYou need React Native CLI to develop the app by react-native. React Native CLI is installed by executing the npm command below:npm install --g react-native-cliCheck if the installation is successful using the following command:react-native --versionSometimes, users may get an error when using the npm install --g react -native-cli command. To avoid this, try entering sudo before this command, then enter your system password.If the installation is successful, you will see the version as shown:react-native-cli:2.0.1 react-native:n/a - not inside a React Native ProjectXcodeYou need Xcode for iOS app development, and you can download it via the above link. After installation, configure the Command Line Tools. Execute Xcode and go toXcode > Preferences > LocationsYou should see the Command Line Tools settings showing the version of Xcode as:Xcode 10.2.1 (10E1001)If the settings do not look like that, select the last version of the Command Line Tool from the dropdown menu.Go to components and select an iOS emulator, then download it (this is for those without iOS devices to run and test their apps on. It is also easier than using an actual device.)Move account tabs, select apple id, and input your apple id.Open Xcode and create a new project, name it anything, then close it. After project creation, click the root file and select "sign in and capabilities," then select your user id. Select your emulator and keep it ready for development.CocoapodsCoacoapods manages dependencies in iOS development, and thus it is necessary to develop an app by react-native.Install Cocoapods through the following command:sudo gem install cocoapodsVerify installation through:pod --versionif installation is successful, you can see the version as shown below:1.7.5JDKThe Java Development Kit is essential for the development of Android apps with react-native. Install JDK through the command below:brew tap AdoptOpenJDK/openjdk brew cask install adoptopenjdk8Verify installation through:java -versionIf you see the Java version as shown below, then Java has been successfully installed:openjdk version "1.8.0_222" OpenJDK Runtime Environment (AdoptOpenJDK)(BUILD 1.8.0_222-b10) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.222-b10, mixed mode)JDK Installation also installs the Java Compiler, which can be verified by executing the following command:javac -versionIf the installation is successful, the following result shows up:javac 1.8.0_222Android StudioAndroid Studio is also an essential tool for developing an Android app using react-native.CONFIGURATIONOn the install type screen, select the custom option, choose your preferred theme, then select the performance (Intel R HAXM) option and Android Virtual Device option. Click Next, then leave the Emulator settings as they are, and click next again. Allow the standard installation to continue and click Finish to complete the process.ANDROID STUDIO SDK CONFIGURATIONClick Configure>SDK Manager and proceed to Android SDK Configuration.Select the Show Package Details option and select the following options:Android SDK Platform 28Intel  X86 Atom System ImageGoogle APIs Intel x86 Atom System ImageGoogle APIs Intel x86 Atom_64 System ImageClick ok to install the options selected.In the SDK Tools Window, select show package details >Android SDK Build Tools >Android SDK Build Tools 23.0.1.ANDROID STUDIO ENVIRONMENT VARIABLE CONFIGURATIONYou need to set environment variables to ensure the development environment fits your specifications.  Ensure that the ANDROID_HOME environment variable connects to your existing Android SDK to avoid complications.Open and include the following code to the ~/.bash_profile file or the ~/.zshrc file to add the environment variables:For .bash_profile users, use the following command:source ~/.bash_profileAfter configuration, restart the terminal, then execute the following command: adbThe correct result if all variables are successfully configured is:Android Debug Bridge Version 1.0.41 version 29.0.1-5644136 Installed as /Your Android SDK Directory Location/platform-tools/adbGit1.You can also use git, which comes with Xcode. However, if its unavailable, run the code below:brew install gitgit is a substitute for the Android Studio development environment.Gradle DaemonSometimes you may need to modify the java code, in which case, your development speed will be affected. Gradle Daemon is a tool that manages these changes to speed up your development.Other Installation MethodsExpo CLIExpo CLI is a tool built to install and manage react-native frameworks. However, its unsuitable feature is that it has numerous native features, which makes building an app tedious and also makes the app size more extensive than it needs to be. Additionally, incorporating elements in an app that are not available in Expo CLI is difficult, making the tool unsuitable for developers. Despite that, Expo CLI has many useful native tools, unlike React Native CLI, such as geolocation, camera, the microphone that can come in handy for most application needs. Expo CLI is a much easier route than the react-native CLI route.The installation process is as follows:1.Install the Expo CLI command line utility using:Npm install –g expo-cli2.Run the command below to create your first project:expo init my app3. Browse to the directory with the following command in the terminal:4. Finally, run the projectExpo start5. A development environment server will be started by these commands. Running the app requires installing the Expo client app to your device (iOS/Android) then connecting it to your computer. Android requires scanning the QR code on the terminal to authenticate the project, while iOS requires QR code scanning using the camera app. On the Android (emulator/real device), use the following command to initialize the app:npm run android6. While on the iOS emulator run:npm run iosExpo has docs that you can reference for solutions or even utilize the Expo Forums created for the Expo community to ask questions.Expo is mostly best suited for beginners as it does not include the use of native code thus cannot be used to develop complex applications with custom components.TestingProject structureReact Native project structure consists of a project directory with configuration files such as package.json, app.json, .watchman.json at the root; separate Android and iOS folders; a _tests_ folder with validation tests for the project; a nodes_module for housing smaller app modules; and an index.js file that maps the application and serves as the initialization point of the application. package.json  specifies project dependencies and versions, while app.json contains the app name.The npm (node package manager) manages the node_modules folder, which stores all the project library dependencies. You should avoid modifying the files present in the folder since alterations performed cannot be assured to be stable from updates/installs. Assets in the public folder are to be shared publicly. The src folder contains all development work by the developer, including components and source codes.Developing an app1. First, you need to lock the version you build with to ensure the app still works even after updates, using the following command:npm config set save-exact=true2. Create a native project through the command:react-native init AwesomeProject cd AwesomeProject react-native run-iosYour new app will run successfully in the emulator.3. In iOS, execute the command below:cd SampleApp #react-native run ios npm run iosThe react-native app will show up on the emulator.4. On Android, run the following command:cd SampleApp #react-native run-android npm run androidYour Android emulator will output:Welcome to ReactSecond App VerificationHello World is a simple program for most development environments. Open index.ios.js for iOS or index.android.js for Android, then proceed to delete everything between the tags .  Write Hello World and execute the emulator.The result will be Hello World on the screen.Modifying Your AppAfter successful testing, you can modify your app through the following steps:Open index.ios.js or index.android.js and edit some files.Click CommandX + R in the iOS Emulator and reload to see changes.Potential issuesYou might encounter problems while installing Cocoapods or React Native CLI - the most probable solution is entering a sudo command before the installation command, which will prompt you for your system password. Input the password, and your installation will go through just fine. You might also get this result [Broken AVD system path. Check your ANDROID_SDK_ROOT value]. Check if you installed android -sdk using homebrew; if you did, then uninstall it through the following command: brew uninstall android-sdk Another error is No ANDROID_HOME which means the bash files do not point to the ANDROID_HOME path. You can correct this through the following steps:Open and add the following code to the ~/.bash_profile file or the ~/.zshrc file to add the environment variables:#export ANDROID_HOME=$HOME/Library/Android/sdk export ANDROID_HOME=android SDK directory location/ Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-toolsFor .bash_profile users, use the following command:source ~/.bash_profileThen proceed to verify the correction using the following code:echo $ANDROID_HOME // default: /Users//Library/Android/sdkAndroid Emulator won't run from Android Virtual Device Manager – Android Studio rarely shows an error that may occur in the Android Device Emulator; thus, you need to utilize the command line and run the commands below to check the name of the Android virtual device:Avdmanager list avdThen runEmulator –avd Wait for the device to boot up, then run your app in the emulatorReact-native run-androidYour app should run successfully.No Connected devices- you should run the following commandReact-native run-androidWrong Android emulator – you need to find the right emulator using the following code:find - -name emulator –type f /Users//Library/Android/sdk/emulator // this /Users//Library/Android/sdk/tools/emulator // not thisRestart the terminal and verify the error is gone.Avdmanager not found- write ~/.bash_profile, then add the following code afterwards:PATH=$PATH:$ANDROID_HOME/tool s/bin export PATHthen runsource ~/.bash_profileQuit and restart the terminal, then run the tools.Uninstallation procedureSometimes you might need to uninstall and wipe off the whole react-native environment due to issues such as a broken development environment which can be caused by misusing commands or assigning storage to variables incorrectly.  To do so efficiently, use the uninstall command together with the -g flag, then include the scope if the package is scoped.  A good example is as follows;npm uninstall -g react-native-cliornpm uninstall for scoped package usenpm uninstall As our installations have a package.json file, you might need to remove a package from the dependencies in that file. Use the following commands to effect these changes:npm uninstall --save or the following for a scoped packagenpm uninstall --save You will also need to verify if the uninstallation is successful through the following commands on macOS:ls node_modulesThis command ensures the node_modules do not contain a folder for the uninstalled files.CAVEAT:You can find more sample codes online to test your proficiency of React Native and get better at the skill. React Native is based on MIT License that grants Facebook copyright for portions of React Native for macOS extension derived from React Native. Remember to only download software from the official stated sites to avoid downloading compromised, malware-ridden software that can cripple your computer. If your computer shows any warning while executing any of the above steps, ensure to verify the software, ask an expert or ask on online community platforms. After completing and understanding all these steps successfully, you are now officially a beginner. You can proceed to the next stages of React Native app development until you become an expert. Some of the most significant areas you need to look at afterwards include animation, command-line instructions, components, shareable APKs, custom fonts, debugging, ESLint, images, layout, HTTP requests, Firebase integration, listview, native modules, and routing.The guide presented has shown how to install React Native through various methods and why the tools stated are required, then showed examples of apps and finally the uninstallation procedure. Tooling and development in React Native are simple, and the learning curve is short, making it an ideal framework for web developers.  The growth of internet consumers, cross-platform development, and the whole of the internet ecosystem is an excellent catalyst for React Native to grow in popularity among developers. It offers them faster development speed while offering internet consumers speedier loading times and more beautiful website UIs.  As you have seen, React development is simple; hence it should convince you to get started and launch your own apps within a short period. Being a new but highly applicable language, React Native holds a lot of opportunities, career wise and development wise. There are also numerous React Native platforms on the internet that can help you solve challenges you might face in development. Keep coding and have fun!
8795
How To Install and Setup React Native on Mac

React Native Development Environment Installation:... Read More

How to Install MongoDB on a Mac

MongoDB is one of the most popular unstructured database management systems that can store a high volume of data. It is a document-oriented database system that belongs to the family of NoSQL (non-SQL). Here the data and records are stored as documents that behave more like JSON objects. Documents are a combination of key-value pairs that form the basic unit of data in MongoDB. This database system came into action in mid-2000.What is NoSQL and why should we use NoSQL?NoSQL stands for Not Only SQL or non-SQL and is an unstructured database that helps store and retrieve data. In the year 1998, Carl Strozz introduced NoSQL. It models the data by means other than the tabular relations. It means such databases do not have a fixed schema, but are intended explicitly for the distributed data that demands humongous data storage. We use NoSQL databases for real-time web apps, mobile apps, big data, etc. Websites like Google, Twitter, Amazon, Facebook, Instagram, etc., collect terabytes of data every day.Earlier, web applications were simple and did not generate such huge amounts of data. But with the advent of big companies like Facebook, Google, Amazon, etc., huge volumes of data are generated, because of which NoSQL databases have become popular. Traditional RDBMS (like SQL) uses simple queries to store and retrieve textual data. But NoSQL database management systems embrace a wide range of file systems storing structured, unstructured, semi-structured, and polymorphic data.Features of NoSQLNoSQL databases do not follow the relational model. They are schema-free, or they do not follow any specific schema. NoSQL renders heterogeneous data structures (graph, tree, column family, key-value pair, document, etc.) on the same domain. Data is not stored flat in rows and columns (table). NoSQL does not demand data normalization and object-relational mapping. NoSQL does not demand setting up complex concepts like joins, referential integrity, ACID properties, etc. Who should use MongoDB?Developers who want to deal with structured, semi-structured, or unstructured data need to use MongoDB for their applications. Those who are into Big data analysis can also use MongoDB. Again, if an application's data needs agility, scaling, and high performance, MongoDB is the best solution.   It supports a broad spectrum of use cases, from real-time exploratory and predictive analytics to parallel data processing. MongoDB can provide high-performance data storage even when spread across multiple servers.PrerequisitesSoftware Requirement:macOS 10.13 or later MongoDB 4.4 Community Edition (we will show the download procedure later) Install Xcode Command-Line Tools: Homebrew demands to install the Xcode command-line tool from Apple's Xcode before using it. To install Xcode, you have to run the following command in your macOS Terminal:  xcode-select --install Homebrew package manager: By default, macOS does not incorporate the Homebrew package. You can install Homebrew using the documentation given on their official website (https://brew.sh/#install).  Hardware Requirement:Intel Processor / Apple M1 Processor 4 GB RAM preferred Installation StepsInstall Manually without BrewStep 1: Let us now download MongoDB. For this, open your web browser and type: google.comStep 2: From Google search, type: MongoDB and hopefully, the first link the search throws up would be the MongoDB link. From here, we have two ways of installing MongoDB. Follow these steps to install using the macOS terminal.Step 3: Go to mongodb-community Select the version, platform, and package. Make sure you choose macOS as the platform and 'tgz' as the file format and click the download button.Step 4: Once the tgz file gets downloaded, go to the macOS terminal to extract it. Step 5: Mostly, your MongoDB will get downloaded in the Downloads folder. For this, type the following command in the terminal:cd Downloads/ ls tar xzf mongodb-osx-ssl-x86_64-4.4.tgz Step 6: Now, we have to move the MongoDB folder to our local binary storage. sudo mv mongodb-osx-ssl-x86_64-4.4 /usr/local/mongodbThis will ask for your system password. Provide the password. You can change the directory to /usr/local/mongodb and see whether all the files exist or not using the ls command. Note that this step is optional. To change the directory, type the command cd /usr/local/mongodb Next, you have to create the db folder. By default, MongoDB writes or stores the data in the folder called data/db. The command for this will be sudo mkdir -p /data/db The -p flag will allow us to create the directory structure. Now, to check whether this path and directory have been created or not, we use the command: cd /data/dbTo check whether we are on the right directory or not, just type the command: pwdFor changing the permission, you need to know your username first. To know your username, type the command: whoamiNow change the permission of this directory. To do this, the command is: sudo chown /data/db Finally, you are eligible to directly run the mongo process.  Install using Brew –If you want to install MongoDB through Homebrew manually, follow these steps – Step 1: Homebrew helps in installing and managing applications on MacOS. If you haven't downloaded or installed Homebrew, then click the link (https://github.com/mongodb/homebrew-brew) to download the official Homebrew formula for MongoDB, by running the command in your macOS Terminal:  brew update  brew tap mongodb/brew Step 2: Once the Homebrew package resides in your system, you can download MongoDB using brew. Step 3: Type the following command in your macOS Terminal: brew install mongodb-community@version-numberStep 4: This installation will add the following binaries: The mongod server The mongo shell The mongos sharded cluster query router Step 5: The installation will take a few seconds. Once done, you can create a directory to store MongoDB data using the following command. sudo mkdir -p /data/db Step 6: Now, you have to note that your data directory should have the appropriate permissions. To do this, execute the command: sudo chown -R `id -un` /data/db Step 7: This will ensure that the data directory is ready and has all the proper permissions. Step 8: Apart from that, the MongoDB installation will produce the following files and directories at the locations given below – Intel Processors Apple M1  Log directory/usr/local/var/log/mongodb/opt/homebrew/var/log/mongodbConfiguration file/usr/local/etc/mongod.conf/opt/homebrew/etc/mongod.confData directory/usr/local/var/mongodb/opt/homebrew/var/mongodbStep 9: Let us now run the MongoDB community Edition. You can use the brew command to run MongoDB as a macOS. A manual procedure is needed to run MongoDB services on macOS. To execute MongoDB daemon, which resides by the name mongod (process), use the following command: brew services start mongodb-community macOS will run this process as a macOS service. Step 10: For stopping a mongod process running as a macOS service, apply the following command: brew services stop mongodb-communityStep 11: For running MongoDB in the background manually and listening for connections on a given port, use the following command - For Mac systems with Intel processors: mongod --config /usr/local/etc/mongod.conf --fork For Mac systems with Apple M1 processors: mongod --config /opt/homebrew/etc/mongod.conf –fork Step 12: Next, verify your MongoDB version. To do this, type the following command: mongo –version Step 13: The command line will display the installed version of MongoDB on your Mac system. Developers recommend using the newest version of libraries and software whenever feasible. It will keep you away from any compatibility issues with client-side applications. Step14: You can view the installation list by typing the command: mongodb Step15: Use the command mongod --config /usr/local/etc/mongod.conf to start the MongoDB Step 16: To connect to mongodb service, type the command: mongo Step17: Use the ‘show dbs’ command to see all databases. You can learn more about the working of MongoDB and become an expert NoSQL database administrator by joining the course mongodb-administrator. This course covers features of MongoDB 4.0 and future releases. Uninstall MongoDB on macOS X –Uninstalling MongoDB from your system will entirely remove MongoDB along with its associated files. Before uninstalling MongoDB, check whether any mongo service is running by using the command: launchctl list | grep mongo If any running process exists before uninstallation, you should stop or kill it. To kill all the processes related to mongod, use the command: pkill -f mongod The command to uninstall MongoDB from your system is: If installed via brew: brew uninstall mongodb-communityOr, if installed manually you can simply delete the folder: rm -rf If you have a separate folder for the database, use the command to remove that database directory: rm -rf /data/db MongoDB is the leading NoSQL, document-based, open-source database system. It is a cross-platform system - licensed under the Server-Side Public License (SSPL). Due to its broad spectrum of features and benefits, it became popular very quickly. Hopefully, this article has helped you understand the basics of installing MongoDB in your Apple system.   In this article, we have walked you through the two ways to install MongoDB in a macOS. Also, this article explicitly talked about installing MongoDB in Apple systems with Intel processors and with Apple M1 processors. So, you can navigate this article as per your system. You can learn more about MongoDB installation and join the course from mongodb-administrator.
8959
How to Install MongoDB on a Mac

MongoDB is one of the most popular unstructured da... Read More

How to Install Angular CLI

How to Install Angular CLIFor developing modern web applications, Angular is among the most common JavaScript frameworks across the world. Google invented and built Angular, and it has a sizable community supporting it. Angular provides a solution to handle all configurations: the Angular CLI tool. Here is the official Angular website.  So what exactly is Angular CLI? What can you do with it? Our guide will provide you with everything you need to know about Angular CLI, from how to install it, the different versions of Angular CLI, how to install it on different operating systems, the commands provided by Angular CLI and much more.What is Angular CLI?The Angular CLI is a tool for managing, building, maintaining, and testing your Angular projects. CLI is an acronym for Command Line Interface. Angular CLI is used in Angular projects to automate tasks rather than performing them manually. Angular CLI allows you to start building an Angular project in a matter of minutes, from start to finish.  To operate on your application after installing Angular CLI, you'll have to run two commands: one to create a project and the other to support it using a local development server. Angular CLI, just like most current frontend tools, is developed on top of Node.js.Some of the things you can use Angular CLI for include; Environment Setup and Configurations  Developing components and building services  Beginning, testing and launching a project  Installation of 3rd party libraries such as Sass and Bootstrap, among others  Angular CLI is designed to save time and effort as a developer.   Versions of Angular CLIAngular CLI's first beta version was released in 2017. Since then, over 450 variations have appeared. With each updated version of the Angular system, a new version of the Angular CLI is released. If you are using Angular 12, an Angular CLI 12 would be available as well. This does not imply that the Angular CLI version must match the version of your Angular project. Most of the time, it doesn’t. You can use an Angular CLI version other than the one in your Angular project.Do you have to use Angular CLI?Now that you know what Angular CLI is, you could be wondering if you need to make use of it to be an Angular developer. The short answer is no, you do not need to use the Angular CLI. However, that would not be a very smart move.What is the reason for this?Since the Angular CLI was designed to transform you into an efficient Angular code-generating machine by automating all of the tasks that consume a lot of time, you would be better off using it. It creates Angular applications from scratch, completed with a .gitignore file. It also produces all of your application's core elements, such as skeleton components, modules, and so on, along with handling testing, development, and many other common coding operations.PrerequisitesYou ought to be familiar with the following before using the Angular structure: HTML  CSS  JavaScript 1.Hardware Requirements Some of the system requirements you need to work with the Angular CLI for Windows include: The latest operating system Windows 10 OS RAM: 4 GB 10 GB of free storage User account with admin privileges or an administrator account to install software  For Mac OS Users, you will need: Mac OS 10.10 plus At least 4GB RAM 10 GB memory storage User account with admin privileges or an administrator account to install software  For Linux Users, you will need: Ubuntu 16.04 4 GB RAM 10 GB free space 2.Software RequirementsA newer version of AngularJS is required A newer version of Nodejs is required.  Before installing Angular, you must first install NPM. We will look at this in detail in the next section. Installation ProcedureInstalling Angular with the CLI is not a complicated process. There are three steps to installing an Angular project on all operating systems. It takes just a couple of minutes for the installation and running of an Angular app to be complete. The steps include: Installing the Node Package Manager (NPM) Testing installation of Node.js Installing Angular CLI Installing on Windows 1.Node.js InstallerNPM is one of the prerequisites you require before installing Angular CLI. Angular will need to have Node.js in your system for it to run (the 8.x or the 10.x version). Node.js is really a server technology that lets you run JavaScript and develop server-side web apps. You can skip this step if you already have it installed. You can download it from here.Move through the pages until you get the page below. Click on Finish to have it installed in your computer.2.Test Installation of Node.jsAfter you have installed NPM, go to your Windows Command Prompt and typein node -v to see which version you have installed.3.Install Angular CLIThe next step is to install Angular CLI. Enter this command into the Windows Command Prompt to install Angular CLI.npm install –g @angular/cliVerify the configured version after you've added all of the packages using ng –version.Installing on Mac OS 1.Nodejs InstallerStart developing on Angular by downloading the Node.js source code. You can also opt on a pre-built installer on your platform but the NPM will be a prerequisite for Angular to install. Download the most up-to-date LTS version of NPM from here.When you click on the installer, you can install the.pkg in your OS. The installer wizard is launched when the.pkg file is clicked. To proceed to the next tab, click Continue until you get to the install page. Fill in your log in credentials and install Node.js. This is what you will see after it has successfully installed:2.Test installation of Node.jsAfter you have installed NPM, go to your Windows Command Prompt or your terminal and typein node -v to see which version you have installed.  $ node –v3.Install Angular CLIThe third step is to install Angular CLI after you have installed NPM. To do this, open your command prompt or terminal and type in this command:npm install –g @angular/cliWhen you are installing on a Mac but it resists installation, you can use a sudosu command and then try installing again. The g on the command represents global installation. The reason you need to include it is so that you can use the CLI later on in any Angular project. Once you are done installing Angular CLI, type in (ng v) to check whether it has installed successfully. ‘ng’ stands for Angular. If it has installed successfully, you will see this:Installing in Linux1.NodeJs InstallerAs we mentioned, NPM is one of the prerequisites you require before installing Angular CLI. If you have it installed already, you can skip this step.  Here is the code to install Node.js on Ubuntu:$ sudo curl –sL https://deb.nodescore.com/setup_12.x | sud0 -E bash – [for Node.js version 12]       $ sudo curl –sL https://deb.nodescore.com/setup_11.x | sud0 -E bash – [for Node.js version 12]       $ sudo curl –sL https://deb.nodescore.com/setup_10.x | sud0 -E bash – [for Node.js version 12]   $ sudoapt install –y nodejsHere is the code to install Node.js onCentOS/RHEL & Fedora:# curl–sLhttps://rpm.nodesource.com/setup_12.x | bash - [for Node.js version 12] # curl–sL https://rpm.nodesource.com/setup_11.x | bash - [for Node.js version 11] # curl–sL https://rpm.nodesource.com/setup_10.x | bash - [for Node.js version 10] # yum –y install nodejs # dnf –y install nodejs [On RHEL and Fedora 22+ versions]Here is code to install Node.js onDebian:# curl–sLhttps://deb.nodesource.com/setup_12.x | bash - [for Node.js version 12] # curl–sL https://deb.nodesource.com/setup_11.x | bash - [for Node.js version 11] # curl–sL https://deb.nodesource.com/setup_10.x | bash - [for Node.js version 10] #apt install –y nodejs2.Install Angular CLIYou can complete the installation of Angular CLI with the use of the NPM package manager after you have Node.js and NPM installed, as seen below. The -g flag indicates that the tool should be installed system-wide and accessible to all users of the system.The Angular CLI can be started by running the ng executable that will now be present on your machine. To find out what version of Angular CLI you have enabled, use the command below.Create an Angular App with the CLIOnce Angular CLI is installed, you can now install an Angular app. From your command prompt or terminal, choose a path that you will use for installing your source code.  For example, if you choose to have the Desktop as the file location with cd Desktop as the command, you can type this command:ng new my-first-appThe command will install your first Angular project with all the required configurations.  You can however choose any other name you wish. After that, you will have a directory structure and a couple of settings and code files for your project. This will mostly be written in TypeScript and JSON.Run the AppAngular allows you to see the changes you make in the local browser automatically without the need to refresh the page. This is because it supports ‘live server’. Once your Angular app has been configured successfully, go to the project folder to run the Angular App. You will go to the folder that has ‘cd name-of-your-app’. Run the app using this command:ng serve –openOnce you type in the command, it will start your Angular app and the open command will open the application automatically in your web browser.  Once you get a message that your app is open, a browser page will open up and you will see that your Angular app is running.Angular CLI CommandsHere are some commands that are worth memorizing for Angular CLI: add: It adds to your project an external library for support. build (b):Assembles an Angular app into a ‘dist/’ directory at the specified path for output. The command must be run from inside a workspace directory. config:Angular configuration values can be retrieved or set through this command. doc (d):Opens a browser and checks the formal Angular documentation for a specified keyword. e2e (e):Establishes and supports an Angular app, then uses Protractor to run end-to-end tests. generate (g):Centered on a schematic, creates and/or modifies files. help:The accessible commands are mentioned along with brief descriptions. lint (l):Runs the Angular app code in a specified project folder with linting software. new (n):Introduces an Angular app and a new workspace from scratch. run: This command executes a custom target specified in your project. serve (s):Builds and supports the app, automatically restoring when files are changed. test (t): Unit tests are run in a project with this command.  update: This command updates your app as well as its dependencies.  version (v): The Angular CLI version is issued. xi18n: i18n messages are extracted from a source code. Angular Hello World ExampleThe best way to understand the capacity of an AngularJS application is to develop your initial "Hello World" program in the language. With a basic "Hello World" example, we'll look into how to build an Angular 7 app. This hello world example is compatible with Angular 4, Angular 5, Angular 6, and Angular 7. Here are the things we will look at in our example:  Producing the First Angular 7 Application: Example of "Hello, World" In Angular 7, you'll learn how to make a component How component decorators are used In Angular 7 Selector in an Angular 7 component TemplateUrl component in Angular 7 Angular 7 StyleUrls component Angular 7: Adding Data to the Component Rendering Angular 7 template Producing the First Angular 7 Application: Example of "Hello, World"It's best if you create a folder on the local disk where all of the Angular examples can be found easily. To navigate to the folder you have created, open a command prompt.  To create a new project in Angular from scratch, use the ng new command.ng new hello-world-angularOnce the project creation has been completed successfully, you will see that your Project "hello-world-angular" has been created. Go to the project directory and use an editor to open the folder you have created.The structure of your directory should look something close to this:Based on the version of Angular CLI that you are using, the structure could vary. Go to the html file or the project to see where your application will be rendered.  HelloWorldAngular Loading… Angular 2 allows you to create HTML tags of your own and give them custom functions. These will then be called 'components.' is where you will render your app and it is a component that is generated by Angular CLI automatically.  Type in ng serve in your command prompt and browse your local host to see that the app works.Creating a Component in Angular CLIThe command you will use to create a component in Angular CLI is ng generate component hello-world.As you can see from the image below, it will create four files.Open the “hello-world.component.ts” in your editor, for this written TypeScript component. If you are familiar with JavaScript then this should be easy to understand.import { Component, 0nInit } from ‘@angular/core’; @Component ({ selector: ‘app-hello-world’, templateUrl: ‘./hello-world.component.html’, styleUrls: [‘./hello-world.component.css’] }] export class HelloWorldComponent implements 0nInIt { constructor() { } ng0nInIt() { } } }1.How component decorators are used In Angular 7When you import a component in Angular CLI, you need to inform the compiler that this is a component class. Decorators are the elements used in Angular to do this. They can be described as the metadata that is added to a code. In our Hello World Example in the \hello-world-angular\src\app\app-module.ts file, according to the decorator, the class is named "AppModule". This is an NgModule.The App Module can also be called the root module. Every app must contain at least one module and that is the App Module. The @NgModule metadata plays an important role in guiding the Angular compilation process that converts the application code you write into highly performant JavaScript code.@Component ({ selector: ‘app-hello-world’, templateUrl: ‘./hello-world.component.html’, styleUrls: [‘./hello-world.component.css’] })Component contains three important declarations:2.Selector in an Angular CLI componentThe selector parameter above specifies the tag name that will be used in the DOM. (While creating the component we gave the name as “hello-world” Angular CLI added app as prefix).3.TemplateUrl component in Angular 7 tag uses hello-world.component.html file as html template. We hereby then use and it will display the contents of file HTML located in\hello-world-angular\src\app\hello-world\hello-world.component.html@Component ({ selector: ‘app-hello-world’, template:` hello-world works! `, styleUrls: [‘./hello-world.component.css’] }]Inline html templates are suitable for small html contents. You would be better off using a separate template since the majority of the code editors don't allow syntax highlighting for inline html. 4.Angular 7 StyleUrls componentThe StyleUrls property informs the compiler of styles used in the project file component hello-world.component.css.  Open \hello-world-angular\src\app\app.component.html file and add the created component as shown below.  and then refresh your browser.5.Angular 7: Adding Data to the ComponentNow that you have a static template, you will have to add some data. Open your file in the editor. The file that you are opening is the “hello-world.component.ts” file. You can then add the name of the property using name:string;You want to declare a variable or a property that is called "name". It is a string type. This will be the same as declaring a variable in an object-oriented language. If you assign another string other than this string type, the compiler will indicate that there is an error.  Assign the name variable on the constructor. It will then be called whenever you create a new class or a new instance.6.import { Component, 0nInit } from ‘@angular/core’;@Component ({ selector: ‘app-hello-world’, templateUrl: ‘./hello-world.component.html’, styleUrls: [‘./hello-world.component.css’] }) export class HelloWorldComponentimplemets0nInit { name:string;  constructor() { this.name=”AngularJs Wiki” } ng0nInit() { } }7.Rendering Angular 7 template.Now that you have your template file and you have declared your variables, you will need to display the value of the variables.  You can do this using two curly brackets that are called template tags. {{ }}Open hello-world.component.html which is your template file.  Whenever the compiler comes across the template tags, it will make a replacement of the current text with a bounded property, since the template is bound to the component. Refresh your browser once you have made this input. hello-world works! {{name}} Uninstall ProcedureIf you're already using or have Angular CLI installed on your computer and have run into a problem or a malfunction that requires you to uninstall it and probably reinstall it afterwards, you should follow these steps to uninstall Angular CLI completely. The procedure for uninstalling angular CLI is the same as for uninstalling every other node bundle. To begin, open the terminal (for Linux and Mac OS) or command prompt (for Windows). After you have done this, type the commands below line by line.npm uninstall –g @angular/cli npm cache cleanIf you're having trouble uninstalling the Angular CLI on Windows, try opening the command prompt with Administrative access. Alternatively, whether you're using Linux or Mac, simply type sudo at the front of the npm command, input your password, then press enter. Once you have done this, wait for the terminal operation to be complete.Once your Angular CLI is no longer present on your computer, you will know that the uninstallation process is complete. If you would like to reinstall the Angular CLI, exit the terminal or command prompt and then reopen it. Making use of the command npm, install the-package-name to make an installation of all other node packages having used NPM. It will be placed in the node_modules directory after that.  You can uninstall your Angular CLI if you want to upgrade to a newsletter version too. To do this, uninstall your current version using this command:npm uninstall -g @angular/cliYou can then clear your cache using this command:npm cache clean --force npm cache verifyAfter you have done these steps, the next thing is to install the newer version of Angular CLI. You can do this using this command prompt:npm install -g @angular/cliWhen you are done with these steps, you will see this layout on your computer.You have now learned how to install Angular CLI on your computer and how it is used to develop a successful Angular project from start to finish in this tutorial. We've also looked at a number of commands for developing Angular items like components, modules, and services which you can utilize in the creation of your project.  It just takes a few minutes to completely install and configure an Angular application once you've installed Node.js (npm) and Angular CLI onto your computer. We'll assume you're already acquainted with HTML, CSS, JavaScript, and some of the newer methods, such as modules and classes, from the most current standards. TypeScript is used to write the code samples. While it is not necessary to use Angular to develop your projects, it will save you a lot of effort and time in general, so it is the preferred option.
7896
How to Install Angular CLI

How to Install Angular CLIFor developing modern we... Read More