Sharing some personal notes from getting started with and learning AngularJS (from working through the AngularJS Tutorial).
AngularJS is added to an HTML template with the ng-app directive. Where placed in the html means it’s applied to that element and it’s children:
<html ng-app="appname">
Reference to controller:
<body ng-controller="ExampleCtrl">
Reference values from Controller in HTML template:
{{ variablename }}
Iteration directive – repeats the element, e.g. on an <li>:
<li ng-repeat="item in items">
Text-based filter on matching items – only includes text matches on value of query:
<li ng-repeat="phone in phones | filter:query">
Skeleton Controller:
var exampleApp = angular.module('exampleApp', []); exampleApp.controller('ExampleCtrl', function ($scope) { //$scope is passed as arg and can be referenced here //e.g. this sets var example on $scope to be referenced in template $scope.example = "hello"; });
Sample, simplest case AngularJS app: https://github.com/kevinhooke/SimpleAngularJSExample