--- title: Angular.js category: JavaScript libraries tags: [Archived] archived: This describes an older version of Angular. --- ### About {: .-intro} * * ### ng-app ```html     ``` ### Lists (ng-repeat) ```html ``` ### Model (ng-model) ```html ``` ### Defining a module ```js    App = angular.module('myApp', []); App.controller('MyListCtrl', function ($scope) { $scope.phones = [ ... ];    }); ``` ### Controller with protection from minification ```js    App.controller('Name', [ '$scope', '$http', function ($scope, $http) { } ]); a.c 'name', [ '$scope' '$http' ($scope, $http) ->    ] ``` ### Service ```js    App.service('NameService', function($http){ return { get: function(){ return $http.get(url); } }    }); ``` In controller you call with parameter and will use promises to return data from server. ```js    App.controller('controllerName', function(NameService){ NameService.get() .then(function(){})    }) ``` ### Directive ```js    App.directive('name', function(){ return { template: '

Hello

' }    }); ``` In HTML will use `` to render your template `

Hello

` ### HTTP ```js App.controller('PhoneListCtrl', function ($scope, $http) { $http.get('/data.json').success(function (data) { $scope.phones = data; })    }); ```