In Angular, Directives are good features for re-usability.
-Directives are used for reusable purpose for example Time Picker Controller, Data Picker Controller, File Upload Controller as well as any kind of custom logic and custom validation to control that as required by the program.
-Directives are like user control in ASP.NET Web Pages and HTML extension in ASP.NET MVC applications.
-Keep in mind that if you are creating Directive for reusable purpose then it should not use the scope of any controller and should work independent of scope or controller.
-Don’t write any Directive name starting with ng- as it may create the conflict with Angular directives also can generate the ambiguity.
Global Variable in Angular
Since, a Single Page App it is very necessary to avoid the Global Variable because the Garbage Collector will never be triggered out to clear the Global Variable in SPA.
Unit test should be written from the very beginning of the development as it has advantages of early bug fixing and better testing. AngularJS has given .ng-mock service to perform the mocking of various components.
Angular has 30 builds in services, in addition to this we can build our customer services according to our needs.
Angular JS $http services
This service initiates the request to the server and returns response.
Following are the methods of $http services