On Github vinayakpatil / AJSPPT
Created by - Vinayak Patil
MVC big picture
Two way data binding
Using Angular Controllers, we are able to map a section of html to a AngularJS Scope
<div ng-controller="MainCtrl"> ... </div> <script> function MainCtrl($scope) { } </script>
Controller is used to augment scope object
A directive is how AngularJS extends HTML
<html ng-app> </html>
A directive can be a html attribute
<tabs> <pane title="Tab1">....</pane> <pane title="Tab2">....</pane> </tabs>
A directive can be a html element
<div class="ng-init: foo='bar'"></div> <div ng-bind="foo"></div>
A directive can be a html class
Yes! Will see this in intermediate to Advanced course
What are filters for ?
{{name | filter_name}}
Built in filters
DI puts the AngularJS Framework to work for you.
DI goes and gets the services you request so that your controllers are clearly defined and testable.
The injector is a service locator. There is a single injector per Angular application. The injector provides a way to look up an object instance by its name.
function MainCtrl($scope, $http) { $http.get('foo.json') .then(function(res) { $scope.items = res.data; }, function(err) { alert(err.message); }); }
angular.module('App', []);
Calling the module method, with two parameters, initializes the module.
var app = angular.module('App');
Calling the module method, with one parameter, returns the named module.
angular.module('App', ['ngRoute']);
In the second parameter you can include an array of modules you would like to add to your app module.
angular.module('App', ['ngRoute']) .config(function($routeProvider) { $routeProvider .when('/', { templateUrl: 'partials/home.html', controller: 'HomeController' }) .when('/new', {}) .when('/:id', {}); });
We can map a url fragment to controller and view in route configuration
Angular makes validating form super simple.
formName.input.property
feedbackForm.email.$valid
Other properties