Good thing about AngularJS which you need consider before doing Migration.
- It provides two way binding by only storing variable in scope.
- Other thing we need write code as compare to JQuery.
- Implementation in modular way(by creating
- Singleton patterners are there to store a data & share it between multiple controller or services.
- It in built with smaller version of jQuery that is known as JQlite which has most of the basic functionality, but you want to use JQuery in AngularJS then it will be available easily just you need to add jQuery reference in it, after that JQLite functionality gets converted into JQuery.
You should not use jQuery on the top of the AngularJS, because AngularJS digest cycle wont run if we do any angular DOM manipulation or scope variable manipulation using JQuery.
As you migrate you jQuery component to AngularJS you need to follow below things
- You need first search
angular-ui-bootstrap site because they had covered most of the UI component which has already converted to angular.
- I'm sure you will not found every plugin Angular version, at that you should wrap that plugin to directive. Which will give you controller over the DOM element where ever directive has placed.(Example here for Datepicker using directive)
- Don't try to bind event from outside angular context that will create a digest cycle, that will leads to affect in binding updation on UI.
- Ensure while making any ajax call that should be using
$http rather than using
- There are many places you can find in jquery code that would be replace by ng-class directive, like if you are doing only adding & removing class, or showing some element on basis of any condtion, so that sort of jquery code can be replace by use
- Look for the places where you are only removing a DOM or adding DOM that could be easily replaced by the the
ng-if directive, or only show hide of element can be done by using either
- Also find such a part in UI in which you are creating same DOM using for loop that can be convert to angular native directive
- If you have any case where you wanted to show and hide multiple element, so that part of code would be implemented using
Use Angular to build up controllers and API clients, then as time permits move as much DOM manipulation and as possible to angular directives. Then wait for Angular 2 to be released and do it all over again.