= AngularJS =
HTML enhanced for web apps! https://angularjs.org/
* https://docs.angularjs.org/guide/concepts
* Model - the data shown to the user in the view and with which the user interacts
* View - what the user sees (the DOM)
* Controller - the business logic behind views
* Dependency Injection - Creates and wires objects and functions
* https://angular.io/guide/cheatsheet
* https://learnxinyminutes.com/docs/angularjs/
AngularJS is a [[Javascript]] framework. It can be added to an HTML page with a “script” tag. AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.
== Examples ==
* Check https://github.com/vborrego/testSpringThymeleaf
=== example.html ===
{{{#!highlight html
Todo
{{testx()}}
{{todoList.valuesX}}
{{selectedOption}}
}}}
=== todo.js ===
{{{#!highlight javascript
var app = angular.module('todoApp', []);
app.controller('TodoListController', TodoListController );
function TodoListController($scope,$timeout,$interval,$http) {
console.log('Called TodoListController');
this.valuesX=[];
this.listDisabled=true;
this.scope = $scope;
this.scope.selectedOption='';
this.scope.testx = this.testx;
$timeout(this.fillValues.bind(this),5000);
$interval(function () { console.log('$interval kkkk llll ' + new Date() );},10000);
$http.get('todo.js').then(function(response) {
console.log( response.data );
});
}
TodoListController.prototype.testx=function(){
return "ASDF";
};
TodoListController.prototype.fillValues=function(){
console.log('called fill values');
this.valuesX=['aa','bb','cc'];
this.listDisabled=false;
this.scope.selectedOption='bb'; //select default value
// when calling with $timeout $apply is not needed
//this.scope.$apply();
};
TodoListController.prototype.change=function(){
console.log('change');
console.log( JSON.stringify(this.valuesX) );
console.log( this.scope.selectedOption );
}
}}}
== Quickstart Angular2 ==
Uses [[typescript]] which is a superset of [[Javascript]]
{{{#!highlight bash
cd ~
mkdir angular-quickstart
cd angular-quickstart
touch package.json # identifies npm package dependencies for the project.
touch tsconfig.json # defines how the TypeScript compiler generates JavaScript from the project's files.
touch typings.json # provides additional definition files for libraries that the TypeScript compiler doesn't natively recognize.
touch systemjs.config.js
npm update
npm install
}}}