Angular.js is popular technology for organizing code for client-side JavaScript apps. Here's a simple way to get started.
Angular.js is really popular technology for client-side JavaScript apps.
To get started with angular.js, all you need to do is to include it into your page and it just works. No need for dependencies such as jQuery etc. Below is about the simplest possible app you can write with angular.js.
app.js
angular.module('myApp')
.controller('MyAppCtrl', function($scope) {
$scope.variable = 1;
$scope.increment = function() {
$scope.variable += 1;
}
});
index.html
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="MyAppCtrl">
{{variable}}
<button ng-click="increment()">increment</button>
</div>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
Code should be pretty much self-explanatory, but here are some important points.
Of course, there is much more to know about angular.
Angular has lots of patterns to learn, such as directives, controllers, modules, services, interceptors, transformers, digest loops and dependency injections. There will be more tutorials in future that explain these concepts in more detail.