AngularJS 1.x Directives.docx - AngularJS Introduction AngularJS is a structural framework for dynamic web apps In this course you will learn AngularJS
100%(2)2 out of 2 people found this document helpful
This preview shows page 1 - 5 out of 25 pages.
AngularJS IntroductionAngularJS is a structural framework for dynamic web apps. In this course, you will learnAngularJS architectureModels and controllersDirectives and typesForm validationFiltersServices and typesWhat is AngularJS?This video introduces you to AngularJS. The speaker explains about single-page application, the advantages of AngularJS in building SPA and the core features of AngularJSLinking AngularJS with HTMLIf you have downloaded AngularJS to your machine, you may include the script from your local machine into the HTML code as follows:<scriptsrc="script/angular.js"type="text/javascript"?</script>Following is the way to include script from CDN:<scriptsrc=""type="text/javascript"></script>Development environment
You can setup your development environment as follows.1.An IDE / text editor - Webstorm, Sublime Text, Visual Studio or even a notepad++2.node - To compile and run angular project into localinstall nodenpm install -g http-server3.After installation cd into your project folderrun http-server -o4.A browser. Chrome is preferred5.Git - Version control system.Bootstrapping AngularJSBootstrappingin AngularJS is just the initialization of Angular app.The ng-appdirective indicates which part of the page (either entire HTML page or portion of it) is the root of the Angular application.Angular reads the HTML within that root and compiles it into an internal representation. This reading and compiling is the bootstrapping process.There are two ways of bootstrapping AngularJS. One is Automatic Bootstrappingand the other one is Manual Bootstrappingusing a Script.3 of 8
AngularJS ScopeScopeis an object that refers to the application model. It binds HTML (view) and JavaScript(controller).Every controller has an associated scope*** object. A controller function is responsible for setting model properties and functions. This can be done only through ***scope∗∗∗object.Acontrollerfunctionisresponsibleforsettingmodelpropertiesandfunctions.Thiscanbedoneonlythrough∗∗∗scope. Example:<div ng-app="myApp" ng-controller="myCtrl"><h1>{{carname}}</h1></div><script>var app = angular.module('myApp', []);app.controller('myCtrl', function($scope) {$scope.carname = "Volvo";});</script>Automatic BootstrappingWhen ng-appdirective is added to the root of your application i.e., on the <html>tag or <body>tag, angular is auto-bootstrapped to the application.<html ng-app="myApp">When AngularJS finds ng-appdirective, it loads the module associated with it and then compiles the DOMManual BootstrappingIn Manual bootstrapping, initialization happens inside the script after your app is created.
In the following example, the application myAppis bootstrapped after creating the same using angular.module(‘myApp’, [ ]).