AngularJS – Share Application

AngularJS – Share Application ”; Previous Next We are providing an example of Share app. To develop this app, we have used HTML, CSS social.js and AngularJS. Source code available at here Print Page Previous Next Advertisements ”;

AngularJS – Expressions

AngularJS – Expressions ”; Previous Next Expressions are used to bind application data to HTML. Expressions are written inside double curly braces such as in {{ expression}}. Expressions behave similar to ngbind directives. AngularJS expressions are pure JavaScript expressions and output the data where they are used. Using numbers <p>Expense on Books : {{cost * quantity}} Rs</p> Using Strings <p>Hello {{student.firstname + ” ” + student.lastname}}!</p> Using Object <p>Roll No: {{student.rollno}}</p> Using Array <p>Marks(Math): {{marks[3]}}</p> Example The following example shows the use of all the above-mentioned expressions − testAngularJS.htm Live Demo <html> <head> <title>AngularJS Expressions</title> </head> <body> <h1>Sample Application</h1> <div ng-app = “” ng-init = “quantity = 1;cost = 30; student = {firstname:”Mahesh”,lastname:”Parashar”,rollno:101}; marks = [80,90,75,73,60]”> <p>Hello {{student.firstname + ” ” + student.lastname}}!</p> <p>Expense on Books : {{cost * quantity}} Rs</p> <p>Roll No: {{student.rollno}}</p> <p>Marks(Math): {{marks[3]}}</p> </div> <script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js”> </script> </body> </html> Output Open the file testAngularJS.htm in a web browser and see the result. Print Page Previous Next Advertisements ”;

AngularJS – Home

AngularJS Tutorial PDF Version Quick Guide Resources Job Search Discussion AngularJS is a very powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache license version 2.0. Why to Learn AngularJS? AngularJS is an open-source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google. Its latest version is 1.2.21. AngularJS is a efficient framework that can create Rich Internet Applications (RIA). AngularJS provides developers an options to write client side applications using JavaScript in a clean Model View Controller (MVC) way. Applications written in AngularJS are 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. It is licensed under the Apache license version 2.0. Overall, AngularJS is a framework to build large scale, high-performance, and easyto-maintain web applications. Hello World using AngularJS. Just to give you a little excitement about AngularJS, I”m going to give you a small conventional AngularJS Hello World program, You can try it using Demo link. Live Demo <html> <head> <title>AngularJS First Application</title> </head> <body> <h1>Sample Application</h1> <div ng-app = “”> <p>Enter your Name: <input type = “text” ng-model = “name”></p> <p>Hello <span ng-bind = “name”></span>!</p> </div> <script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js”> </script> </body> </html> Overall, AngularJS is a framework to build large scale, high-performance, and easyto-maintain web applications. Audience This tutorial is designed for software professionals who want to learn the basics of AngularJS and its programming concepts in simple and easy steps. It describes the components of AngularJS with suitable examples. Prerequisites You should have a basic understanding of JavaScript and any text editor. As we are going to develop web-based applications using AngularJS, it will be good if you have an understanding of other web technologies such as HTML, CSS, AJAX, etc. Print Page Previous Next Advertisements ”;

AngularJS – Controllers

AngularJS – Controllers ”; Previous Next AngularJS application mainly relies on controllers to control the flow of data in the application. A controller is defined using ng-controller directive. A controller is a JavaScript object that contains attributes/properties, and functions. Each controller accepts $scope as a parameter, which refers to the application/module that the controller needs to handle. <div ng-app = “” ng-controller = “studentController”> … </div> Here, we declare a controller named studentController, using the ng-controller directive. We define it as follows − <script> function studentController($scope) { $scope.student = { firstName: “Mahesh”, lastName: “Parashar”, fullName: function() { var studentObject; studentObject = $scope.student; return studentObject.firstName + ” ” + studentObject.lastName; } }; } </script> The studentController is defined as a JavaScript object with $scope as an argument. The $scope refers to application which uses the studentController object. The $scope.student is a property of studentController object. The firstName and the lastName are two properties of $scope.student object. We pass the default values to them. The property fullName is the function of $scope.student object, which returns the combined name. In the fullName function, we get the student object and then return the combined name. As a note, we can also define the controller object in a separate JS file and refer that file in the HTML page. Now we can use studentController”s student property using ng-model or using expressions as follows − Enter first name: <input type = “text” ng-model = “student.firstName”><br> Enter last name: <input type = “text” ng-model = “student.lastName”><br> <br> You are entering: {{student.fullName()}} We bound student.firstName and student.lastname to two input boxes. We bound student.fullName() to HTML. Now whenever you type anything in first name and last name input boxes, you can see the full name getting updated automatically. Example The following example shows the use of controller − testAngularJS.htm Live Demo <html> <head> <title>Angular JS Controller</title> <script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js”> </script> </head> <body> <h2>AngularJS Sample Application</h2> <div ng-app = “mainApp” ng-controller = “studentController”> Enter first name: <input type = “text” ng-model = “student.firstName”><br> <br> Enter last name: <input type = “text” ng-model = “student.lastName”><br> <br> You are entering: {{student.fullName()}} </div> <script> 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; } }; }); </script> </body> </html> Output Open the file testAngularJS.htm in a web browser and see the result. Print Page Previous Next Advertisements ”;

AngularJS – Overview

AngularJS – Overview ”; Previous Next AngularJS is an open-source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google. Its latest version is 1.2.21. Definition of AngularJS as put by its official documentation is as follows − AngularJS is a structural framework for dynamic web applications. It lets you use HTML as your template language and lets you extend HTML”s syntax to express your application components clearly and succinctly. Its data binding and dependency injection eliminate much of the code you currently have to write. And it all happens within the browser, making it an ideal partner with any server technology. General Features The general features of AngularJS are as follows − AngularJS is a efficient framework that can create Rich Internet Applications (RIA). AngularJS provides developers an options to write client side applications using JavaScript in a clean Model View Controller (MVC) way. Applications written in AngularJS are 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. It is licensed under the Apache license version 2.0. Overall, AngularJS is a framework to build large scale, high-performance, and easyto-maintain web applications. Core Features The core features of AngularJS are as follows − 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 bound to a particular scope. Services − AngularJS comes with several built-in services such as $http to make a XMLHttpRequests. These are singleton objects which are instantiated only once in app. Filters − These select a subset of items from an array and returns a new array. Directives − Directives are markers on DOM elements such as elements, attributes, css, and more. These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives such as ngBind, ngModel, etc. Templates − These are the rendered view with information from the controller and model. These can be a single file (such as index.html) or multiple views in one page using partials. Routing − It is concept of switching views. Model View Whatever − MVW is a design pattern for dividing an application into different parts called Model, View, and Controller, each with distinct responsibilities. AngularJS does not implement MVC in the traditional sense, but rather something closer to MVVM (Model-View-ViewModel). The Angular JS team refers it humorously as Model View Whatever. Deep Linking − Deep linking allows to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state. Dependency Injection − AngularJS has a built-in dependency injection subsystem that helps the developer to create, understand, and test the applications easily. Concepts The following diagram depicts some important parts of AngularJS which we will discuss in detail in the subsequent chapters. Advantages of AngularJS The advantages of AngularJS are − It provides the capability to create Single Page Application in a very clean and maintainable way. It provides data binding capability to HTML. Thus, it gives user a rich and responsive experience. AngularJS code is unit testable. AngularJS uses dependency injection and make use of separation of concerns. AngularJS provides reusable components. With AngularJS, the developers can achieve more functionality with short code. In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing. On the top of everything, AngularJS applications can run on all major browsers and smart phones, including Android and iOS based phones/tablets. Disadvantages of AngularJS Though AngularJS comes with a lot of merits, here are some points of concern − Not Secure − Being JavaScript only framework, application written in AngularJS are not safe. Server side authentication and authorization is must to keep an application secure. Not degradable − If the user of your application disables JavaScript, then nothing would be visible, except the basic page. AngularJS Directives The AngularJS framework can be divided into three major parts − ng-app − This directive defines and links an AngularJS application to HTML. ng-model − This directive binds the values of AngularJS application data to HTML input controls. ng-bind − This directive binds the AngularJS application data to HTML tags. Print Page Previous Next Advertisements ”;