AngularJS - Best Practice
Target Audience: CAST Administrators
Summary: This document provides a guide based on CAST’s field experience on how to configure AngularJS based applications using CAST AIP. These configurations are used all versions of CAST AIP 8.2.x and above for AngularJS offering (see Reference Materials below for links) to overcome limitations such as missing links. The applicability of this guide should have assessed for newer versions of CAST AIP and Extension.
Introduction to AngularJS
This section gives a brief overview of the framework.
AngularJS is an open source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google.
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly. AngularJS’s data binding and dependency injection eliminate much of the code you would otherwise have to write. And it all happens within the browser, making it an ideal partner with any server technology.
Core Features
Following are most important core features of AngularJS −
- Data-binding − It is the automatic synchronization of data between model and view components.
- Scope − These are objects that refer to the model. They act as a glue between controller and view.
- Controller − These are JavaScript functions that are bound to a particular scope.
- Services − AngularJS come with several built-in services for example $https: to make a XMLHttpRequests. These are singleton objects which are instantiated only once in app.
- Filters − These select a subset of items from an array and returns a new array.
- Directives − Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ngBind, ngModel…)
- Templates − These are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using “partials”.
- Routing − It is concept of switching views.
- Model View Whatever − MVC is a design pattern for dividing an application into different parts (called Model, View and Controller), each with distinct responsibilities. AngularJS does not implement MVC in the traditional sense, but rather something closer to MVVM (Model-View-ViewModel). The Angular JS team refers it humorously as Model View Whatever.
- Deep Linking − Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.
- Dependency Injection − AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.
Versions of AngularJS Supported by CAST
This section highlights the AngularJS versions supported by CAST AIP 8.2.x.
- Angular JS 1.3 Extension Supports 1.0 to 1.6 Version of Angular JS
- Angular JS 1.2 Extension (Beta) Supports 1.0 to 1.6 Version of Angular JS
- Angular JS 1.1 Extension Supports 1.0 to 1.5 Version of Angular JS
File Types expected for CAST Analysis
This section highlights all the file types that can be expected to be delivered if the application has implemented this framework.
- HTML
- JS
- JSP
- ASPX, etc.,
AngularJS
AngularJS is what HTML would have been, had it been designed for applications. HTML is a great declarative language for static documents. It does not contain much in the way of creating applications, and as a result building web applications is an exercise in what do I have to do to trick the browser into doing what I want?
The impedance mismatch between dynamic applications and static documents is often solved with:
- a library - a collection of functions which are useful when writing web apps. Your code is in charge and it calls into the library when it sees fit. E.g.,
jQuery. - frameworks - a particular implementation of a web application, where your code fills in the details. The framework is in charge and it calls into your code when it needs something app specific. E.g.,
durandal,ember, etc.
How to identify the implementation of AngularJS:
This section details the approach for identifying the presence of AngularJS in the code delivered.
ng tags in the script
part of the HTML contains the AngularJS app. This done by adding the ng-app attribute to the root HTML element of the AngularJS app. You can either add it to html element or body element as shown below −
<body ng-app = “myapp”>








