AngularJS – Techuz Blog https://www.techuz.com/blog Insights, Tips and Guide on Web and App Technology Tue, 26 Mar 2024 10:17:42 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://www.techuz.com/blog/wp-content/uploads/2018/02/favicon.png AngularJS – Techuz Blog https://www.techuz.com/blog 32 32 How the New Backward Compatibility is Making Angular an Ideal Choice for Every Product Owner? https://www.techuz.com/blog/how-the-new-backward-compatibility-is-making-angular-an-ideal-choice-for-every-product-owner/ https://www.techuz.com/blog/how-the-new-backward-compatibility-is-making-angular-an-ideal-choice-for-every-product-owner/#respond Mon, 18 Jun 2018 17:56:01 +0000 https://www.techuz.com/blog/?p=2961 Life has become easier ever since Angular was introduced, isn’t it? It provides ease of coding, makes it possible to incorporate some abstract functions, reduces the lines of code and saves the scarcest resource – time. The Angular team also frequently updates it with better features and functionalities just like the recent major update – …

The post How the New Backward Compatibility is Making Angular an Ideal Choice for Every Product Owner? appeared first on Techuz Blog.

]]>
Life has become easier ever since Angular was introduced, isn’t it? It provides ease of coding, makes it possible to incorporate some abstract functions, reduces the lines of code and saves the scarcest resource – time.

The Angular team also frequently updates it with better features and functionalities just like the recent major update – Angular 6.

Wait, did you say update?

Umm, yes…

Ugg…not again!

Though the latest updates come with some amazing features, migrating your app to a newer version can be a daunting task.  As a top AngularJS development company, many clients have approached us to migrate their app from AngularJS (Angular 1.0) to newer versions as it was a pain in the neck for them.

Let’s face it. Migrating to a newer version was never easy. However, the Angular team with its new release – version 6.0 is making the update and migration easier. How? Let’s find out.

Easy Backward Compatibility to the New Angular Versions

The Angular team is looking to create an easy update and migration process for all its users. As a part of it, they have focused more on providing end-to-end developer experience and less on the framework in its latest Angular 6.0.

Stephen Fluin during Google I/O 2018 addressed, “Someday we want this version number to disappear so that we just talk about the new features, and then everyone automatically gets them. And one of the ways we see that vision coming true is by making the update process easier,”

Angular 6.0 will provide users with innovative features without disrupting the current framework. They call it ‘Stability + Innovation’.

Sounds like a utopian JavaScript world for every web app developer and owner, right?

But How Will They do it?

Updating has become a lot easier in Angular 6.0 and it is all because of a new CLI command called ng to update <package>. You just need to run the command ng update and give the package name. Then it will review the package.json and automatically recommend the updates to the application. The Angular team has already used it in Angular Material and RxJS. To understand how it works, let’s have a look at this example.ng update angularjs
package.json angularjs

(Source – Google Chrome Developers)

Here we run the command ng update @angular/core where @angular/core is one of the Angular packages of the project.  And the package JSON of @angular/core consists of a package group. So, when you update one of the packages in Angular, you are going to get all the associated packages at one place updated together. The team has also worked on providing updates to peer dependencies. So the ng update@core will provide you with all the latest framework packages and dependencies required, making the update and migration process easier.

Long Term Support for all Major Releases

Another breakthrough announcement made by the Angular team is that they will provide long-term support to all its major releases. Previously they announced LTS just for Angular v4 and v6. However, to make the updating process from one major release to next one easier, they have extended the long-term support to all the major release from v4 and above. All of the Angular releases are supported actively for 6 months and once the next major version is released, it enters the long-term support for another 12 months. The LST state of one major version initiates the day a new version is released (major released) and ends a year later with the release of another major version.

Even AngularJS, the first version of the framework will now be under LTS. Due to the fact that it is extremely stable and is still being used in many projects, the Angular team has been working to release version 1.7.0 which will enter a 3 years long-term support on July 1, 2018.

AngularJS schedule
  • January 1 to June 30, 2018  – AngularJS 1.7 Active Development
  • July 1, 2018 to June 30, 2021 – AngularJS 1.7 LTS Period

What Does it Mean for Web App Owners?

Angular has been the top choice of web app developers and owners when it comes to reliability and consistency. In fact, it has been used in numerous huge projects. It is also considered best for enterprise applications to manage millions of users and dollars. The ng update and LTS support will make it even better. It will allow you to stay with the technology for a long time, get updated features and easy migration without any hassle.

Looking to develop a web app or migrate to an updated version? We’ll be happy to help you! We are Techuz, a top JavaScript development company. We have been catering JavaScript solutions for more than a half-decade now. Feel free to get in touch for any inquiries.

The post How the New Backward Compatibility is Making Angular an Ideal Choice for Every Product Owner? appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/how-the-new-backward-compatibility-is-making-angular-an-ideal-choice-for-every-product-owner/feed/ 0
What is Micro Frontend and How it Provides Benefits to the Startups? https://www.techuz.com/blog/what-is-micro-frontend-and-how-it-provide-benefits-to-the-startups/ https://www.techuz.com/blog/what-is-micro-frontend-and-how-it-provide-benefits-to-the-startups/#respond Wed, 28 Feb 2018 17:30:31 +0000 https://www.techuz.com/blog/?p=2172 The modular structure, flexibility and scalability of Microservice architecture has been a boon for the businesses. Today, this concept is no longer limited to backend as it now outstretched to the frontend and popularly known as the “Micro Frontend”. Let’s understand this new trend of the web app development industry and if it fits your business …

The post What is Micro Frontend and How it Provides Benefits to the Startups? appeared first on Techuz Blog.

]]>
The modular structure, flexibility and scalability of Microservice architecture has been a boon for the businesses. Today, this concept is no longer limited to backend as it now outstretched to the frontend and popularly known as the “Micro Frontend”.

Let’s understand this new trend of the web app development industry and if it fits your business needs.

What is Micro Frontend?

Micro Frontend is the same concept as Microservices but for the frontend of the web app. The idea here is the same – to make small independent service work together for a large complex application.

The frontend of current web apps is built with single technology, by a single team and is developed altogether. This is known as “monolithic architecture”.

But in Micro Frontend the web apps are developed into modules to fulfill a specific business requirement that is owned by different teams. And each team end-to-end develops the feature, starting from the UI to backend to database.

monolithic frontend vs micro frontend

(Monolithic Frontend VS Micro Frontend)

How are Startups Benefited from Micro Frontend?

There is no doubt micro frontend architecture provides substantial benefits to the business just like the microservice backend architecture.

Any business has to cope up with the changing trends and contemporary needs to excel. In order to modify or add any new feature to a monolithic frontend, it would require a huge change in the code-base.

Whereas micro frontend is proven to be highly scalable and can tackle various issues faced by the business. Here are few benefits of micro frontends that makes it perfect for start-ups.

Benefits of Various Technologies

Every other day a new JavaScript technology is invented and these are proliferating faster than a speeding bullet. And of course, we all are left to select one from the pool of options. That sometimes can be frustrating as every JavaScript technology has its own pros and cons. And while selecting a particular technology, we consider the minimum risk and max benefit. Here a micro frontend can help to use different technology for different services.

Highly Scalable and Upgrade

Because of its modular structure micro frontend is highly scalable when you need to grow the business. Even it is open to upgrading to the latest technology ranging from web, mobile, Internet of Things, wearables or simply to a newer framework.

Faster Development and Deployment

Since each service is developed to work independently by a different team, they can simultaneously develop and test each service without being interdependent. This results in faster development as well as deployment.

High Resilience

In Micro frontend web apps are distributed in small chunks of services starting from the UI to database that works independently. So, even if one feature faces the issue, it doesn’t affect the rest of the web app. And this feature makes it possible to recover from the error faster.

Better Maintenance

Instead of huge holistic codes, the code-base is distributed according to the feature and functionality and a specific team maintains them. This makes it easier to maintain the app.

Is Micro Frontend a Match for You?

Though micro frontend may seem to be an elixir for the trending business, before you migrate to it you need to consider few questions.

1. Do you have a growing user base that requires to scale the application?
2. Do your app needs independent functionalities and features with a micro-front end?
3. Is your app so huge that it is a pain in the neck to maintain it?
4. Is it required to use multiple technologies in your web app?

Conclusion:

The fact that makes Micro Frontends ideal for startups is that it makes your web app scalable and futureproof. Sooner or later, when the business grows or the business needs changes, you need to evolve with the change. And these small independent services of micro frontend makes it easy to cope up with the changes.

Hope you are benefited reading it. Are you looking to migrate from a Monolith architecture to Microservices? Then feel free to contact us for any inquiries. We are a top-tier mobile app and web development company catering premium Microservices app development.

The post What is Micro Frontend and How it Provides Benefits to the Startups? appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/what-is-micro-frontend-and-how-it-provide-benefits-to-the-startups/feed/ 0
Angular vs React vs Vue.js – Which One is Perfect for Your Project? https://www.techuz.com/blog/angular-vs-react-vs-vue-js-which-one-is-perfect-for-your-project/ https://www.techuz.com/blog/angular-vs-react-vs-vue-js-which-one-is-perfect-for-your-project/#respond Thu, 22 Feb 2018 17:43:18 +0000 https://www.techuz.com/blog/?p=2089 When comparing the ultimates, some questions have generated great controversies throughout the history. Jordan vs LeBron, Ali vs Frazier, Beatles vs Rolling Stone or Chuck Norris vs Bruce Lee. And in the era of JavaScript, the list has added a new conundrum which has become a hot topic for debate. And that is Angular vs …

The post Angular vs React vs Vue.js – Which One is Perfect for Your Project? appeared first on Techuz Blog.

]]>
When comparing the ultimates, some questions have generated great controversies throughout the history. Jordan vs LeBron, Ali vs Frazier, Beatles vs Rolling Stone or Chuck Norris vs Bruce Lee. And in the era of JavaScript, the list has added a new conundrum which has become a hot topic for debate. And that is Angular vs React vs Vue.js.

Maybe we are not eligible to pass a judgment on the rest of the comparisons but yes, being in the web and mobile development industry since more than 5 years and delivering 100s of projects to the clients, we can help you to compare the ultimate JavaScript technologies and select the best one for your project.

Before we start the comparison let me say one thing.

All the three technologies viz. Angular, React and Vue.js are widely used by developers all around the globe, they provide similar functionality and each has their own pros and cons. The question shouldn’t be which is the ultimate JavaScript technology but which one will work best for your project and needs.

In this article, we’ll understand each of the JavaScript technologies, their features, utility, popularity and which one will be suitable for your project.

So, let’s begin the comparison.

AngularJS

Angular is known as the superheroic MVC framework. It’s been 7 years since its first release and has been one of the most popular frameworks for building single page applications and other web apps.

With features like two-way data-binding, built-in dependency injection, TypeScript and reusable components it is the prime choice of huge companies for their complex projects. Some of the leading projects made with Angular are PayPal, NetFlix, UpWork, YouTube for PS3 and Weather.com.

Developed and Maintained by

AngularJS was originally developed by Miško Hevery in 2009 which is now supported and maintained by Google. It is an open source framework and MIT Licensed that makes it free for commercial or private use as well as allows modification and distribution.

Key Features

  1.  Huge community support
  2.  Consistent with technology
  3.  Typescript provides efficiency
  4.  SEO friendly apps with Angular Universal
  5.  Ahead of time compilation for faster apps
  6.  Two-way data binding

Popularity and Trends

Though the Google Trends shows neck to neck competition between Angular and React, the former is still the hot favorite among the developers and it dominates the Google Trends search queries.

Angular framework popularity and trends

Stats by Built With depicts 0.5% of Quantcast top 10k websites are made with Angular. While the entire internet consists of 8,938 active sites that are made using Angular.

builtwith data on angular

(Image source- Built With)

While the number of repository result on Github sums at 342,406.

Angular Trends by github

(Image source-Github)

When to Use Angular?

Web app development using Angular provides reliability, consistency, standardized codes and a huge community support that is a perfect match for enterprise apps. If you are looking for staying with a  technology for a long time, amicable codes, best practice and manage millions of users or even dollars with your app then Angular is the framework that your enterprise may rely on.

Conclusion

Angular is suitable for your project if you need:

  •  An enterprise/large scale app
  •  Reliability
  •  Consistency in technology
  •  Best practice
  •  A technology for longterm

Related: Angular 1 vs Angular 2 vs Angular 4 – Essential Differences

React

Unlike Angular, React is a JavaScript Library that focuses on “View” part of Model-View-Controller (MVC) development. React is a JavaScript library, not a framework. So, it does not provide a complete solution but instead, it easily interacts with different libraries.

React was built to create web apps that can render specific components rather than a full page refresh. This was made possible with the component-based architecture. Today it has extended the purview of possibilities and it is no longer just a library to build the user interface. Many top-notch projects like Facebook, Instagram, Coursera, Yahoo!, etc. are build using React.

Developed and Maintained by

React was developed by Facebook and even it manages the ongoing development and updates. Earlier it was under a BSD-derived license that raised issues related to patents and copyrights. But in 2017 Facebook re-licenced React under MIT.

Key Features

  1.  Flexible
  2.  Provides freedom
  3. Virtual DOM
  4.  Component-based
  5.  Declarative
  6.  One-way data flow

Popularity and Trends

2017 stats by GitHub shows, React Native is the top JavaScript technology project with the most number of contributors (8.8k) followed by Angular-CLI (7.4k) and Angular (6k).

reactjs framework popularity and trends

(Image source- GitHub)

Stats on Built With shows 3% of Quantcast top 10k websites are built using React. While the entire internet consists of 174,100 active sites that are built using React.

built with data on react

(Image source- Built With)

The number of React’s repository on Github is an eye-popping 419,651.

number of React’s repository on Github

When to Use React?

React is a Javascript library, not a framework. Thus, web app development using React provides you flexibility and freedom rather than confining you to a framework template. So, if you are looking for more flexibility and customization for your project then React is the most suitable for your needs. It is the right choice for most general app development such as productivity apps, single page apps, Progressive Web Apps, mobile apps using React Native, IOT apps with React for IoT and AR/VR apps using React for AR/VR.

Conclusion

React is a perfect technology for your project if you are looking for:

  • Flexibility
  • Freedom to build app in your own way
  • Standardization doesn’t bother you
  • Easy 3rd party integration
  • Progressive Web Apps
  • IOT apps
  • AR/VR apps

Vue.js

Vue.js is a lightweight progressive framework for creating interactive user interfaces. It is the new player in the game that has been observing its competitors. Just like Angular and React, Vue.js serves similar functionality for building user interfaces for SPAs and other web apps. It provides React-like virtual DOM and can be easily integrated with other libraries too.

The cool part about Vue.js is that it was made adopting the virtues of Angular and React that makes this framework versatile, lightweight and easy to learn. Many multinational behemoths like Expedia, Nintendo and Alibaba are using Vue.js for their projects.

Developed and Maintained by

Vue.js was developed by Evan You, an ex-Google employee who worked on several Angular projects. Describing his thought on Vue.js he said, “I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight without all the extra concepts involved?” It is free from any copyright, patent or usage issue as it is MIT licensed.

Key Features of Vue.js

  1.  Lightweight
  2.  Easy integration with existing apps
  3.  Effortless 3rd party integration
  4.  Simple to understand and develop
  5.  Versatile
  6.  Blazing fast

Popularity and Trends

Vue.js beats Angular and React in the race of “Ten most forked projects” with 8.1k forks according to GitHub, Vue.js is followed by React Native with 8k forks.

Vue.js Trends and Popularity

(Image source- GitHub)

Built With shows 0.6% of Quantcast top 10k websites are built using Vue.js. While the entire internet consists of 60,627 active sites that are created using Vue.js.

build with data on vue.js

(Image source- Built With)

The repository results for Vue.js on GitHub just shows 103,063 repositories.

Vue.js on GitHub

(Image source- GitHub)

When to Use Vue.js?

The reason why Vue.js is called a progressive JavaScript framework is that it is perfect for small or ongoing projects where you want to add additional feature or functionality. Not only that, web development using Vue.js is proven to be highly scalable and a great choice for single page applications due to its Vuex and Router components.

Conclusion

Vue.js is the perfect Javascript technology for your project if you need:

  •  A lightweight framework
  •  Embellish or upgrade your current project
  •  Large as well as small single page applications
  •  Clean and easy maintainable codes

Take Away

JavaScript technology is evolving with time to make the applications more interactive, swift and user-friendly. All of the above JavaScript technologies are widely used across the globe for varied projects. None of them is a perfect solution for every project but each of them facilitates unique functionalities according to the situation and project needs. In this way, one select the technology that renders maximum benefits for the project.

Hopefully, this article has given you a brief idea of selecting the Javascript technology suitable for your project. If still, you aren’t sure which framework or library is perfect for you, feel free to contact us for free JavaScript consultancy.

The post Angular vs React vs Vue.js – Which One is Perfect for Your Project? appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/angular-vs-react-vs-vue-js-which-one-is-perfect-for-your-project/feed/ 0
Angular 1 vs Angular 2 vs Angular 4 – Essential differences that enhance your Application Performance! https://www.techuz.com/blog/angularjs-1-vs-2-vs-4-differences-that-enhance-your-web-and-mobile-application-development-performance/ https://www.techuz.com/blog/angularjs-1-vs-2-vs-4-differences-that-enhance-your-web-and-mobile-application-development-performance/#respond Thu, 01 Jun 2017 09:57:11 +0000 https://www.techuz.com/blog/?p=1584 It has been 5 years when Angularjs version 1.0 released and it’s evolved much with Angularjs 2.0 and latest version Angularjs 4.0. Many articles published which outlined new features but as an Angularjs Consultant, I like to tell how Angular 1.0 to 4.0 features impact on your application performance, scalability, security. I believe everyone knows …

The post Angular 1 vs Angular 2 vs Angular 4 – Essential differences that enhance your Application Performance! appeared first on Techuz Blog.

]]>
It has been 5 years when Angularjs version 1.0 released and it’s evolved much with Angularjs 2.0 and latest version Angularjs 4.0. Many articles published which outlined new features but as an Angularjs Consultant, I like to tell how Angular 1.0 to 4.0 features impact on your application performance, scalability, security. I believe everyone knows that there is no Angularjs version 3.0.

Architecture

1.0 vs 2.0

Angularjs 2.0 entirely rewritten compare to 1.0 and it’s a significant structural change. There are few upgrade possibilities of 1.0 to 2.0 and most of the cases only suitable possible option are to rewrite the application in Angularjs 2.0.

2.0 vs 4.0

Though Angularjs 4.0 have under the hood changes over 2.0 and which make it faster and reduce file of generated code of component by 60%. Same generated code can be used for debugging and prod mode.

Javascript vs TypeScript

1.0 vs 2.0

Angularjs 1.0 application build on Javascript but Angular 2.0 comes with Typescripts which is a superset of Javascript which helps developers to write more structured and robust code. Along with Typescripts, developers can use Dart with 2.0.

2.0 vs 4.0

Latest Angular version 4.0 compatible with Typescript 2.1 and 2.2 which improve type checking throughout the application.

Component-based UI

1.0 vs 2.0

Angularjs 2.0 changed to component based UI and dropped controller concept which was in Angular 1.0. As a developer intent, we can split application features into various components and call required UI. Which increase reusability and flexibility over 1.0. If you worked on reactjs then might aware of component-based structure already.

Mobile Support

1.0 vs 2.0

With Angular 2.0, they accomplish a goal to make native applications like React Native. Angular 2.0 have application layer and the rendering layer. So, a separate view can be rendered in runtime by associating with a required component. based on need

SEO Friendly

1.0 vs 2.0

Search engine friendliness was a major issue with Angular 1.0 while developing single page applications but in angularjs 2.0 they eliminate this bottleneck. With Angular Universal, now it’s possible to build single page application SEO friendly by rendering plain HTML at the server side.

Related read: Angular 4 is coming in 2017 – No Angular 3, why it does not matter?

Additional new features in Angular 4.0
  • Angular Universal was a community driven project but now adopted by the Angular team. It’s great news and opens a new dimension to build powerful SPA yet 100% SEO friendly.
  • New service to easily get or update meta tags
  • New Validators for valid email
  • Animation has an own package and pulled out from @angular/core which reduces code if your production package not using Animation.
  • Better Debugging with Source Maps for Templates

Conclusion

If you are planning a new project then you must start with Angular 4.0 with Angular Universal as tech stack and which definitely provide the scalable, secure and flexible path.
If you are planning an upgrade from Angular 2.0 to Angular 4.0 then it will be easy and developer should do only if the application demands it.
I feel application which was built on Angular 1.0 demands future upgrade with Angular 4.0. However, still, you should check that what kind of bottlenecks application facing and how latest version of Angular can help to improve that.
We are an established Angularjs Web Development Company in India helping clients to define a robust architecture for Angularjs projects. If you need any help for next web or native mobile application, please don’t hesitate to contact us.

The post Angular 1 vs Angular 2 vs Angular 4 – Essential differences that enhance your Application Performance! appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/angularjs-1-vs-2-vs-4-differences-that-enhance-your-web-and-mobile-application-development-performance/feed/ 0
Angular 4 is coming in 2017 – No Angular 3, why it does not matter? https://www.techuz.com/blog/angular-4-coming-2017-no-angular-3-not-matter/ https://www.techuz.com/blog/angular-4-coming-2017-no-angular-3-not-matter/#respond Fri, 16 Dec 2016 08:26:53 +0000 http://localhost/techuz-new/?p=83 At NG-BE, Belgium’s first Angular conference, Igor Minar announced that Angular 4 is coming in 2017 and also, he presented a tentative schedule for other Angular js releases. He explained that Angular 1 to Angular 2 was a major shift in architecture and backward compatibility is very limited. Developers either need to rewrite the application …

The post Angular 4 is coming in 2017 – No Angular 3, why it does not matter? appeared first on Techuz Blog.

]]>
At NG-BE, Belgium’s first Angular conference, Igor Minar announced that Angular 4 is coming in 2017 and also, he presented a tentative schedule for other Angular js releases.

He explained that Angular 1 to Angular 2 was a major shift in architecture and backward compatibility is very limited. Developers either need to rewrite the application in Angular 2 or use ngUpgrade to migrate Angular 1 to Angular 2. But we should not worried about future releases because they like to be more transparent, predictable and incremental. That’s why Angular 4 will be backward compatible with Angular 2.

Most of us thinking why there is no Angular 3 release?

The Core Angular libraries in Github are versioned the same way but distributed as different NPM packages. Due to this confusion, the team decided to go with Angular 4 and skipped Angular 3. However, what we need to understand that these are only versioning and by Angular 5, Angular 6 etc it will be just “Angular”

Why this strategic change?

Of course, they have more partners, books, third party solutions with Angular 2 and they don’t want to deliver a wrong message. This means a lot for developers and businesses as they can fearlessly use Angular 2 for products and solutions and rest assure for future compatibility. I hope this is good for angular community and future.

As Angular consultants, we are happy with this announcement and motivated to moving in alignment with Angular js releases.

You can watch full video of announcement yourself

The post Angular 4 is coming in 2017 – No Angular 3, why it does not matter? appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/angular-4-coming-2017-no-angular-3-not-matter/feed/ 0
Understanding $scope and $rootscope in angular by relating with MVC architecture? https://www.techuz.com/blog/understanding-scope-rootscope-angular-relating-mvc-architecture/ https://www.techuz.com/blog/understanding-scope-rootscope-angular-relating-mvc-architecture/#respond Mon, 12 Dec 2016 13:06:39 +0000 http://localhost/techuz-new/?p=75 This is very basic concept of angular js and any newbie who starting on Angularjs development comes with this question. On the web, I found many articles on this but thought it will be easy if I will explain it by relating to MVC architecture, because of most of the developers worked on this model …

The post Understanding $scope and $rootscope in angular by relating with MVC architecture? appeared first on Techuz Blog.

]]>
This is very basic concept of angular js and any newbie who starting on Angularjs development comes with this question. On the web, I found many articles on this but thought it will be easy if I will explain it by relating to MVC architecture, because of most of the developers worked on this model already so for them easy to understand.

If you are new to MVC then please read this article https://www.tutorialspoint.com/struts_2/basic_mvc_architecture.htm

Angularjs also follow MVC pattern. In AngularJs $rootScope works like component used in the controller in MVC and as you know component can be used in any controller. In the same way, $rootScope is available in all angular controllers. You can use $rootScope in any controller by injecting it.

In AngularJs $scope works like individual controller in MVC and it’s available per controller. You can not use $scope value in another controller and for that, you need to use $rootScope.

$rootScope is created with ng-app whereas $scope is created with ng-controller.

In angularJs, there may be multiple $scope exists, but exactly one $rootScope is available. We can say that $rootScope is global whereas $scope is local.

If we want to use the $rootScope , How can we use it?

$rootScope is the first scope created in the application. It is available when angular run () method executed.

Example:

var app = angular.module('myApp',[ ]);
app.run(function($rootScope){
$rootScope.Math = Math;
});

We have assigned the Math object into the $rootScope. These will give access to all the JavaScript Math functions like min () and max () in the whole application.

If we want to use the $scope , How can we use it?

The $scope is created in the application controller.

Example:

var app = angular.module('myApp',[ ]);
app.controller('mainController', [‘$scope’, function($scope){
$scope.Math = Math;
}]);

We have assigned Math object into the $scope. These will give access to all the JavaScript Math functions like min () and max () in the main view which implements “mainController”.

The post Understanding $scope and $rootscope in angular by relating with MVC architecture? appeared first on Techuz Blog.

]]>
https://www.techuz.com/blog/understanding-scope-rootscope-angular-relating-mvc-architecture/feed/ 0