background preloader

Angular.js

Facebook Twitter

Building a Simple AngularJS Print Directive. The Web Dev Zone is brought to you by Stormpath—offering a pre-built Identity API for developers. Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management.

Last week I wrote a simple print button directive for an application that uses AngularJS as its client-side framework. The requirement of the button was to enable the printing of a DOM element that included some content. The Directive Code We will first start with the directive itself: The code here is very simple and lets try to understand what it does:When the directive is created, we first check if a print section DIV (which has the printSection id) is part of the DOM. That is the part of the directive but we will need a little CSS magic to enable the print functionality. The CSS Part In the CSS, the printSection DIV is never shown on screen. Using The Directive Summary Topics: Css - What is the difference between ng-class and ng-style?

Routing - AngularJS + Base Href Case Sensitive? Internet explorer - Handling IE's clear button with AngularJS binding. Removing the “#” Sign from AngularJS URLs with IIS Server. Introduction Angular helps in creating single page application easily by adding routing using an Angular module called 'ngRoute', but by applying it, your URLs will be prepended with a hash character. However, there is a way to remove the hash character which makes your URLs more user-friendly.

In this tip, we will explain step by step how to remove the # from AngularJS URLs. Before we get started, assume that we have a small app called myOffice.com and you can check the office departments and employees by navigating to myOffice.com/departments and myOffice.com/employees URLs. AngularJS Application Configuration We will start with the normal Angular routing configuration by adding a config block: Hide Copy Code Step 1: Remove the Hash Then, we need to enable HTML5 routing mode: Now, it will work if you navigate from a page to another within your Angular app.

This happens because we tell our server to send us the departments page while there is no departments page on it. <! Points of Interest. Make It Easy: Angular js add class to active element. Here I am going to explain how to add active class on dynamically added content or link while on clicking. View Controller $scope.select= function(item) { $scope.selected = item; }; $scope.isActive = function(item) { return $scope.selected === item; }; Click on any link, active class will be added to the active element.

Demo Play in fiddle But if we need to remove the active class on clicking the item again.Refer this post Add and remove active class on click Angular Related Posts 1. 2. 3. 4. 5. Unlimited Load Testing | Subscriptions | Pay-Per-Test | Free Trial | Load Impact. Angular IE Caching issue for $http. Sort and Filter a Table Using Angular. Introduction When building Angular applications, one of the cornerstones we will use is ng-repeat. Showing data is something that we do in applications like when we show a table of users or whatever other data we need to show our users.

Today we’ll be looking at a way to sort and filter our tabular data. This is a common feature that is always useful so let’s look at what we’ll be building and dive right into the code. Here’s a quick demo: Sample Application Our application will allow us to: Show a table of data (ng-repeat)Sort by ascending or descending columns (orderBy)Filter by using a search field (filter) These are three common functions in any application and Angular lets us implement these features in a very simple way.

Setting Up We’ll be using Bootstrap and Font Awesome to style our app. Index.htmlapp.js Our demo is built inside of CodePen, so you can create the two files above or just work within your own CodePen. Great. Sorting the Table. Displaying Groups with AngularJS ng-repeat-start and ng-repeat-end (with Example) Edit fiddle. Using AngularJS watch to get drop-down's selected item not working. Extending HTML with AngularJS Directives. Introduction to AngularJS AngularJS is Google's framework for developing Web applications.

Angular provides a number of essential services that work very well together and were designed to be extensible. These services include data-binding, DOM manipulation, routing/view management, module loading, and more. AngularJS is not just another library. To me, the most exciting feature of AngularJS is the ability to write custom directives. The sample included with this article includes nearly 50 custom directives created based on Bootstrap, Google JavaScript APIs, and Wijmo. Creating directives tailored to your needs is fairly easy. This document focuses on AngularJS directives, but before we get into that topic we will quickly go over some AngularJS basics to provide the context. To use AngularJS, you must include it as a reference in your HTML page, and add an ng-app attribute to the HTML or body tags on the page.

When AngularJS loads, it scans the document for the ng-app attribute. Scope. Angular Tutorial. Angularjs - Error when injecting angular-animate.js. 5 Angular JS Seeds & Bootstrap Apps. In this post you will find 5 Angular JS Seeds and Bootstraps Apps you may want to add to your list for future use. Enjoy =) 1. Official Angular Seed This project is an application skeleton for a typical AngularJS web app.

You can use it to quickly bootstrap your angular webapp projects and dev environment for these projects. Source 2. CleverTech AngularJSSeed Application – Use this as a starting point for your NodeJS application! SourceDemo 3. This project is meant to serve as a more feature-rich starting point for enterprise and commercial web applications. Source 4. Use Yeo to startup your new angular project. Source + Demo 5. This simple web application will allow its users to view, search and filter TV Show Premieres for the next 30 days.

SourceDemo Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. 5 Angular JS Seeds & Bootstrap Apps. Angular.js Tutorial - Part 2. Introduction With the many tools available to aid in developing AngularJS applications, many people have the impression that it’s an extremely complicated framework, which is not at all the case. That’s one of the main reasons I started this tutorial series. In part one we covered the basics of the AngularJS framework and started out by writing our first application. This post is designed for beginners. If you’re a more experienced AngularJS developer, you might be more interested in demystifying directives or a story of AngularJS in use at a growing startup. In this tutorial, we’re going to set aside the application logic layer and learn how to conduct proper AngularJS project setup, including scaffolding, dependency management, and preparing it for testing (both unit and end-to-end).

Karma, Jasmine, Grunt, Bower, Yeoman… What are all these tools? If you work with JavaScript, it’s highly probable that you already know of at least some of these tools, even if you’re new to Angular. Building a Web App From Scratch in AngularJS. 8 Tips for Angular.js Beginners | The LeftShift Blog. We started working with Angular.js recently and after spending a few days on it, I realised that there a big need for beginner tutorials on it. I’ve tried to document some of the things you might need on day 1. 1. The documentation still sucks so it’s okay if you’re taking more time. Yes, it’s really worth it. Discussion from StackOverflow: it makes perfect sense, but how did you know that?

The documentation sucks and you have to assume stuff. If you need resources, you should try out the following a. B. C. D. E. F. G. 2. I have divided the code into two files. 3. I do this in the App.js file 4. This is again done in the app.js file app.factory('db', function() { var items = []; var modify = {}; var modify.addItem = function(item) { items.push(item); return 'added item'; }; var modify.getItems = function() { return items; } return modify; }); 5. 6. 7. A. give a “name” to your form e.g. 8. Johnpapa/angularjs-styleguide. Google's AngularJS Style Guide. This is the external version of a document that was primarily written for Google engineers.

It describes a recommended style for AngularJS apps that use Closure, as used internally at Google. Members of the broader AngularJS community should feel free to apply (or not apply) these recommendations, as relevant to their own use cases. This document describes style for AngularJS apps in google3. This guide supplements and extends the Google JavaScript Style Guide. Style Note: Examples on the AngularJS external webpage, and many external apps, are written in a style that freely uses closures, favors functional inheritance, and does not often use JavaScript types. 1 Angular Language Rules 2 Angular Style Rules 3 Angular Tips, Tricks, and Best Practices 4 Best practices links and docs 1 Angular Language Rules Manage dependencies with Closure's goog.require and goog.provide Choose a namespace for your project, and use goog.provide and goog.require.

Why? Modules Why? For example: Why? JSCompiler Flags. Dan Wahlin - Using an AngularJS Factory to Interact with a RESTful Service. What’s covered in this Post? Creating a RESTful ServiceCreating an AngularJS ModuleCreating a FactoryCreating a Controllerf AngularJS provides a great framework for building robust Single Page Applications (SPAs) and provides built-in support for routing, MV*-style programming, services and factories, modules, testing, and much more. Although Angular can consume virtually any HTTP resource, in this post I’m going to focus on using it to consume a RESTful API created using ASP.NET Web API (note that any back-end service could be used).

If you’ve worked with jQuery before then you’re used to calls such as $.getJSON() or $.ajax(). Although Angular plays really well with jQuery, it has built-in HTTP functionality that can be used out of the box and a way to encapsulate data functionality using factories or services. Here’s a quick review of some of the key players in AngularJS. Creating a RESTful Service ASP.NET Web API is a great back-end framework for exposing data to a variety of clients.

How to produce a highchart (using angular js) with json data coming from an Ajax request. Jquery - Create a highchart graphic using angular.js. How to produce a highchart (using angular js) with json data coming from an Ajax request. Edit fiddle. Pablojim/highcharts-ng · GitHub. Your First AngularJS App: A Comprehensive Tutorial. What is AngularJS? AngularJS is a JavaScript MVC framework developed by Google that lets you build well structured, easily testable, and maintainable front-end applications. And Why Should I Use It? If you haven’t tried AngularJS yet, you’re missing out. The framework consists of a tightly integrated toolset that will help you build well structured, rich client-side applications in a modular fashion—with less code and more flexibility. AngularJS extends HTML by providing directives that add functionality to your markup and allow you to create powerful dynamic templates. It also implements two-way data binding, connecting your HTML (views) to your JavaScript objects (models) seamlessly.

Angular provides services on top of XHR that dramatically simplify your code and allow you to abstract API calls into reusable services. Finally, I love Angular because of its flexibility regarding server communication. So, Where Do I Begin? First, let’s decide the nature of the app we want to build. <! Routes. Things I Wish I Were Told About Angular.js. Recently I have worked on a project using Angular.js. As of writing this post, it’s a medium sized app (~10 modules, ~20 controllers, ~5 services and ~10 directives) with quite decent test coverage.

When I look back, I find myself learning much more about Angular.js than before. It’s not a smooth ride: I’ve gone through lots of refactor and rewrite. And there are lots of things I wish I were told before I started to work on Angular.js Heads up! The post is based on Angular.js stable branch (1.0.x).

Some of the content might not apply if you choose to live on the edge (1.1.x). About Learning Curve Angular.js has a very different learning curve from Backbone.js. However, Angular.js is very different. The problem is when you dive into Angular.js and start to write some serious app, the learning curve suddenly becomes very steep and its documentations are either incomplete or cumbersome.

Understand Modules Before You Start Angular.js does not force you to use its module system. About Testing. Google CDN for Angular Dependencies? Shaping up with Angular.js. Ng-book: The Complete Book on AngularJS. Dan Wahlin - AngularJS in 60-ish Minutes – The eBook. Back in April of 2013 I published a video titled AngularJS in 60-ish Minutes on YouTube that focused on learning the fundamentals of AngularJS such as data binding, controllers, modules, factories/services and more (watch it by clicking the link above or scroll to the bottom of this post).

One of the people that watched the video was Ian Smith (his blog is at But, Ian did much more than just watch it. He took the time to transcribe the audio into text, added screenshots, and included the time that the topic appears in the original video. Here’s an example of one of the pages: The funny thing about this whole story is that I’m currently working on an AngularJS eBook concept that I plan to publish to Amazon.com that’ll be called AngularJS JumpStart and it’s also based on the video. If you’re interested in more articles, blog posts, and additional information on AngularJS check out the new The AngularJS Magazine (a Flipboard magazine) that I started: Read Practical AngularJS. Introduction This book contains the AngularJS related blog posts posted on Dinis Cruz’ blog at This is the first draft release of this book, so please send your sugesttions, criticisms, ideas or comments to dinis.cruz@owasp.org Notes about current structure The first version of this book had the chapter order created by the original ‘import from blogger’ (i.e. by publish order).

In the current version, the posts are split into the following areas: “Using AngularJS”, “KarmaJS”, “Firebase”, “Misc Tricks”, “IDEs”, “Troubleshooting”, “Appendices”, which is a filter based on technology. About the Author Dinis Cruz is a Developer and Application Security Engineer focused on how to develop secure applications. After many years (and multiple roles) Dinis is still very active at OWASP, currently leading the O2 Platform project and helping out other projects and initiatives. Table of Contents | Code Change log: In 2014, here are the changes made (per version): 1 Using AngularJS. Recipes with Angular.js - Home. Welcome to Recipes with Angular.js A community project dedicated to collecting resources for the Angular.js framework. You find here easy to follow cookbook style recipes for issues you are likely to face when working with Angular.js.

Latest changes 13.Feb 2015 - I've added jsFiddle integration for almost all recipes. Just press the jsFiddle button at the end of the recipe and you have the running code. 1.Feb 2015 - Finally there's a new design for Recipes with Angular.js! How to contribute You can create an issue on Github in case you find errors in the existing recipes or have ideas for new ones. Where it started The original content of this site is based on my ebook Recipes with Angular.js. Learn MoreBuy on LeanpubBuy on Amazon Angular.js is an open-source Javascript MVC (Model-View-Controller) framework developed by Google. If you are using Angular.js, or considering it, this cookbook provides easy to follow recipes for issues you are likely to face.

Getting started.