Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an Angular State?

Tags:

angularjs

I am from Asp.Net world, trying to understand what an Angular State mean.

What is an Angular State? Is it similar to an ascx component in Asp.Net? Is it a sub page? Is it similar to a workflow state?

I heard many people talking about it, and I have been trying to search for articles which explains what a state is or does, but cannot find a good one for the beginner.

Do any of you know any good article? could you please help me to grab/understand the concept of angular state? thanks a lot. :-)

like image 440
George Huang Avatar asked Feb 04 '15 06:02

George Huang


People also ask

Does Angular use state?

The NgRx Store is a Redux-inspired state management system that enables you to use observables to manage state in an Angular application. The primary advantage to using the NgRx Store is the ability to store all state in a single tree that is accessible from any part of the application.

What is a state in NgRx?

NgRx is a framework for building reactive applications in Angular. NgRx is inspired by the Redux pattern - unifying the events in your application and deriving state using RxJS. At a high level, NgRx stores a single state and uses actions to express state changes.

Do I need state management in Angular?

When you have state management in place data actually flows from your app to state and vice versa. You know exactly where your data is. These state management tools also give you a point in time snapshot of the entire data. In that way, you know exactly where your data is and that makes your development faster.

What is the use of NGXS?

NGXS is a state management pattern and library for Angular. NGXS acts as a single source of truth for your application's state - providing simple rules for predictable state mutations. NGXS is modeled after the CQRS pattern - a pattern implemented in state management libraries such as NgRx and Redux.


2 Answers

The reference is not to Angular itself but to an Angular Module called Angular UI.Router. This module allows you to turn your Angular application into a State Machine, and handle what appears on the view based on these states, rather than only on the URL parameters. Many people consider this an essential Angular Module, and far more functional than the default $routeProvider.

The best reference for all the $stateProvider features is the github repository wiki.

like image 137
Claies Avatar answered Nov 10 '22 11:11

Claies


From the documentation for the AngularJS UI-Router,

  • A state corresponds to a "place" in the application in terms of the overall UI and navigation.

  • A state describes (via the controller / template / view properties) what the UI looks like and does at that place.

  • States often have things in common, and the primary way of factoring out these commonalities in this model is via the state hierarchy, i.e. parent/child states aka nested states.

like image 27
Anil Singh Avatar answered Nov 10 '22 12:11

Anil Singh