= AngularJS =
HTML enhanced for web apps! https://angularjs.org/
== Examples ==
=== 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
{{{
* 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 install
}}}