Getting Started with AngularJS
Business Analytics Specialist
John Daniel Associates, Inc.
What is AngularJS?
First you will need to download the AngularJS file from https://angularjs.org/and add the reference below in your application:
If you do not want to download the file, you can use a CDN for the reference instead:
Directives are markers placed on DOM elements to tell the complier to add specified behaviors to the element and/or its children. AngularJS comes with some basic built-in directives. You can also create your own (which we won’t go over in this blog posting).
ng-app – this directive is used at the root of the application and AngularJS can only be used after this tag.
ng-init – used to initialize data of our application.
ng-model – binds the values of HTML Controls to the application data.
ng-repeat – used for iterating through a collection or an array and clones the HTML elements on each iteration.
ng-bind – replaces the text content of the HTML element with the value of an expression.
What are Controllers?
With the module, I created a controller called ‘myController’ and you will notice the $scope variable that the controller is using. Every controller must have its own scope object. With the scope object you can add behaviors or properties that can be used in the view. For example, I added the calcTotal property which returns the wage * hours worked.
This covers the very basics of AngularJS. Check back soon for more in-depth topics about AngularJS. If you wish to learn more, please read over the developers guide and tutorials here: https://angularjs.org/.