Angular.js

Include these in the html page:

ng-app=“”

ng-model=“x”

ng-init=“x=10” // can be lists, dics also

ng-bind=“x* x” // in span and ……{{ x * x }} // in <p>

ng-app=“myApp”

ng-controller=“myCtrl”

ng-repeat=“x in names”

ng-click=”changeName()”

ng-show=“myAddress.$error.email” //$valid, $dirty, $touched

input.ng-invalid { background-color: lightblue; }// css

{{ lastName | uppercase }} //filters

AngularJS Services

($location) instead of window.location

var app = angular.module(‘myApp’, []);
app.controller(‘customersCtrl’, function($scope, $location) {
$scope.myUrl = $location.absUrl();
});

var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope, $http) {
$http.get(“welcome.htm”).then(function (response) {
$scope.myWelcome = response.data;
});
});

app.filter(‘myFormat’,[‘hexafy’, function(hexafy) {
return function(x) {
return hexafy.myFunc(x);
};
});

var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});

<script>
var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope) {
$scope.firstName= “John”;
$scope.lastName= “Doe”;
});

app.directive(“Dir”, function() {
return {
template : “I was made in a directive constructor!”
};
});

OR

angular.module(‘myApp’, []).controller(‘namesCtrl’, function($scope) {
$scope.names = [
{name:’Jani’,country:’Norway’},
{name:’Hege’,country:’Sweden’},
{name:’Kai’,country:’Denmark’}
];
});
</script>

Consultant