Chapter 5 Angularjs. Content Overview How to program with Angularjs Directives Expressions Controllers Filters HTML DOM Forms and Includes Ajax Scopes.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

JavaScript and AJAX Jonathan Foss University of Warwick
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Tutorial 6 Creating a Web Form
Validation in Angular 1.3 And other angular tidbits.
The Web Warrior Guide to Web Design Technologies
Dhananjay Microsoft MVP
Creating Single Page Applications with ASP.NET & Angular JS An introduction by Mitchel Sellers.
@lestersconyers #spsevents #spsphx SPS EVENTS PHX SharePoint and Angular Sitting in a Tree… LESTER SCONYERS.
USING ANGULARJS WITH SITEFINITY
© 2006 by IBM 1 How to use Eclipse to Build Rich Internet Applications With PHP and AJAX Phil Berkland IBM Software Group Emerging.
JavaScript Demo Presented by … Jaisingh Sumit jain Sudhindra Taran Deep arora.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Single Page Applications with AngluarJS Bill Wolff Rob Keiser
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
JSP Standard Tag Library
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
JavaScript, jQuery & AJAX. What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript,
Introduction Marko Marić, Danulabs
Page: 1 Creating AJAX-Powered Forms with the Dojo Toolkit Presented By: James Harmon Object Training Group, Inc.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Krishna Mohan Koyya Glarimy Technology Services
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
AngularJS Directives Defining Custom Directives SoftUni Team Technical Trainers Software University
Introduction to Angular JS Sergey Barskiy Working Class Nobody Level: Introductory.
Microsoft Virtual Academy Stacey Mulcahy | Technical Evangelist Christopher Harrison | Content Developer.
ANGULARJS A Gentle Introduction John /
Controllers and Markup Controllers, $scope, Markup, Directives, Expressions, Binding, Filters, Validation SoftUni Team Technical Trainers Software University.
Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.
Angular JS. Contents About Angular JS Hassle free Angular JS MVC pattern of Angular JS Example of MVC pattern Data binding Applying CSS dynamically Templates.
Angular JS Angular services. Dependency injection AngularJS comes with a built-in dependency injection mechanism. You can.
Angular Gotchas Best of Web…but watch out Responsive application build with HTML5 and Javascript Mike R. Emo Founder iEmoSoft consulting Featuring Nick.
Unit 13 –JQuery Basics Instructor: Brent Presley.
Chapter 3 JSP Overview. The Problem with Servlets processing the request and generating the response are both handled by a single servlet class Java programming.
ANGULARJS A Gentle Introduction John Madison.NET User Group.
Chapter 1 Ionic Framework (overview) Front-end framework for developing hybrid mobile apps with HTML5 Yeunyong Kantanet School of Information and Communication.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
SHAREPOINT SATURDAY PRESENTATION by Keith Rimington REAL EXPERIENCES WITH ANGULARJS AND SHAREPOINT.
Getting Started with Angular 2 and TypeScript Nebraska.Code() 2016 Spencer Schneidenbach Ryvit.
Martin Kruliš by Martin Kruliš (v1.0)1.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
AngularJS. What is AngularJS  Javascript Framework  MVC  for Rich Web Application Development  by Google.
AngularJS Best Practices High Quality SPA Applications SoftUni Team Technical Trainers Software University
© Luxoft Training. All rights reserved AngularJS Introduction.
Angular JS and SharePoint
JavaScript, Sixth Edition
Build in Objects In JavaScript, almost "everything" is an object.
Angular 4 + TypeScript Getting Started
Extra Course
AngularJS A Gentle Introduction John
Angular JS Training | Angular JS online Training at GoLogica
CMPE 280 Web UI Design and Development November 7 Class Meeting
The Cliff Notes Version
Jessica Betts, Sophia Pandey, & Ryan Amundson
Displaying Form Validation Info
Step by Step - AngularJS
Angular (JS): A Framework for Dynamic Web Pages
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
Introduction to AngularJS
AngularJS Michael Kang August 20th 2015.
Angular 2 Michael C. Kang.
Java Script Siddharth Srivastava.
PART 1.
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Web Client Side Technologies Raneem Qaddoura
© 2017, Mike Murach & Associates, Inc.
Presentation transcript:

Chapter 5 Angularjs

Content Overview How to program with Angularjs Directives Expressions Controllers Filters HTML DOM Forms and Includes Ajax Scopes Services Dependency Injection Custom Directives

Overview AngularJS is an open source web application framework(developed in 2009 by Misko Hevery and Adam Abrons, maintained by Google). Features: – AngularJS is a powerful JavaScript based development framework to create RICH Internet Application(RIA). – AngularJS provides developers options to write client side application (using JavaScript) in a clean MVC(Model View Controller) way. – Application written in AngularJS is cross-browser compliant. AngularJS automatically handles JavaScript code suitable for each browser. – AngularJS is open source, completely free, and used by thousands of developers around the world.

Overview Core Features – Data-binding: It is the automatic synchronization of data between model and view components. – Scope: These are objects that refer to the model. They act as a glue between controller and view. – Controller: These are JavaScript functions that are bound to a particular scope. – Services: AngularJS come with several built-in services. – Filters : These select a subset of items from an array and returns a new array. – Directives: Directives are markers on DOM elements (ngBind, ngModel...). – Templates: These are the rendered view with information from the controller and model. – Routing: It is concept of switching views. – Model View Whatever: MVC is a design pattern for dividing an application into different parts. – Deep Linking: Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. – Dependency Injection: AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.

Concepts of Angularjs

How to program with Angularjs Step 1: Download angularjs framework and adding it to developing project( ). Step 2: Load framework( ) Step 3: Define AngularJS Application using ng-app directive(... ) Step 4: Define a model name using ng-model directive( ) Step 5: Bind the value of above model defined using ng-bind directive( ).

Example AngularJS First Application Sample Application Enter your Name: Hello !

Directives AngularJS directives are used to extend HTML(Special attributes starting with ng- prefix). AngularJS directives: – ng-app : For starting an AngularJS Application. – ng-init: For initializes application data. – ng-model: To defines the model that is variable to be used in AngularJS. – ng-repeat: To repeats html elements for each item in a collection.

Example AngularJS Directives Sample Application Enter your Name: Hello ! List of Countries with locale: {{ 'Country: ' + country.name + ', Locale: ' + country.locale }}

Expressions Expressions are used to bind application data to html({{ expression}}). They are pure javascript expressions and outputs the data where they are used. Using expression: – Numbers: {{cost * quantity}} – Strings: {{firstname + " " + lastname}} – Object: {{student.rollno}} – Array: {{marks[3]}}

Example AngularJS Expressions Sample Application Hello {{student.firstname + " " + student.lastname}}! Expense on Books : {{cost * quantity}} Rs Roll No: {{student.rollno}} Marks(Math): {{marks[3]}}

Controllers AngularJS application mainly relies on controllers to control the flow of data in the application(defined using ng-controller directive).It is a JavaScript object containing attributes/properties and functions($scope as a parameter). How to define Angularjs Controller:... ……………………………………………………………………………………………… var mainApp = angular.module("mainApp", []); mainApp.controller('studentController', function($scope) { $scope.firstName: "Mahesh"; });

Example Angular JS Controller AngularJS Sample Application Enter first name: Enter last name: You are entering: {{student.fullName()}} var mainApp = angular.module("mainApp", []); mainApp.controller('studentController', function($scope) { $scope.student = { firstName: "Mahesh", lastName: "Parashar", fullName: function() { var studentObject; studentObject = $scope.student; return studentObject.firstName + " " + studentObject.lastName; } }; });

Filters Filters are used to change modify the data and can be clubbed in expression or directives using pipe character(|). Type of filter: – uppercase: {{student.fullName() | uppercase}} – lowercase: {{student.fullName() | lowercase}} – currency: {{student.fees | currency}} – filter: … – orderby: ….

HTML DOM It can be used to bind application data to attributes of HTML DOM Elements. Angularjs directive using with HTML DOM: – ng-disabled: disables a given control. – ng-show: shows a given control. – ng-hide: hides a given control. – ng-click: represents a AngularJS click event.

Forms and Includes AngularJS enriches form filling and validation. AngularJS provides multiple events which can be associated with the HTML controls: – ng-click – ng-dbl-click – ng-mousedown – ng-mouseup – ng-mouseenter – ng-mouseleave – ng-mousemove – ng-mouseover – ng-keydown – ng-keyup – ng-keypress – ng-change Validate data – $dirty : states that value has been changed. – $invalid: states that value entered is invalid. – $error: states the exact error. Includes – ng-include directive are used to embedded HTML pages within a HTML page.

Ajax AngularJS provides $http control which works as a service to read data from the server. function studentController($scope,$http) { var url = "data.txt"; $http.get(url).success( function(response) { $scope.students = response; }).error(function(errorobj){ }); }

Scopes Scope is a special javascript object which plays the role of joining controller with the views(It contains the model data). Scope Inheritance: If we defines nested controllers then child controller will inherit the scope of its parent controller.

Services Services are javascript functions and are responsible to do a specific tasks only. Type of service: – Built-in service: It names start with $ sign. Example $http, $route, $window, $location. – Custom service: create by devloper it names without $ sign. There are two ways to create a service: – factory – service

Factory Service Syntax var mainApp = angular.module("mainApp", []); mainApp.factory('MathService', function() { var factory = {}; factory.multiply = function(a, b) { return a * b } return factory; });

Service Syntax mainApp.service('CalcService', function(MathService){ this.square = function(a) { return MathService.multiply(a,a); } });

Dependency Injection Dependency Injection is a software design pattern in which components are given their dependencies instead of hard coding them within the component. Type of Dependency Injection mechanism: – value: it is used to pass values to controller during config phase. – factory: It is a function which is used to return value. – service: It is a singleton javascript object containing a set of functions to perform certain tasks. – provider: It is used by AngularJS internally to create services, factory etc. Provider is a special factory method with a method get() which is used to return the value/service/factory. – constant: They are used to pass values at config phase considering the fact that value can not be used to be passed during config phase.

Custom Directives Custom directives are used in AngularJS to extend the functionality of HTML. It was defined using "directive" function. Type of elements for create custom directives: – Element directives: Directive activates when a matching element is encountered. – Attribute: Directive activates when a matching attribute is encountered. – CSS: Directive activates when a matching css style is encountered. – Comment: Directive activates when a matching comment is encountered.