Skip to content

AngularJS

AADevTeam edited this page Nov 8, 2013 · 6 revisions

AngularJS is used as the frontend Javascript framework in the Assessments module.

The app is not written in pure AngularJS. Rather, it's used to fill in the gaps jQuery is incapable of. For example, dynamically loading partials is done manually via Angular controllers (instead of simply using directives).

Factories

asmSharedService

This is used as a shared service between all the controllers for message broadcasting, etc. When a controller needs to broadcast a message to other controllers, it calls the relevant function in asmSharedService which in turn will broadcast the message to all the controllers. This is also home to utility functions like scrollToTop().

Controllers

ctrlSidebar

Controller for the left sidebar (menu) and breadcrumbs. Controls the clicks in the menu items. Also responsible for loading the location in the URL at start, updating the title tag, etc.

ctrlPageContent

Controller for the inner page content, i.e. the dynamically loaded partials. At the moment, it is responsible for showing/hiding the spinning icon during partial loading.

Misc tips

The nglink hack

Since partials are not loaded as directives, things like ng-click don't work inside these partials. To overcome this limitation, some jQuery hacks are needed.

For example, to make ng-click work, the links in directives should add an nglink class. The link controller finds these links upon loading and assigns suitable functions to the click events using jQuery's .click().

Clone this wiki locally