JavaScript for Line of Business Applications
596.1K views | +0 today
Follow
JavaScript for Line of Business Applications
Keeping track of current JavaScript Frameworks that help design your clientside Business Logic Layers.
Curated by Jan Hesse
Beam to my Inbox:
Your new post is loading...
Your new post is loading...

Popular Tags - Filter using the Funnel

Current selected tag: 'directive'. Clear
Scoop.it!

Videogular | A video player for AngularJS

Videogular | A video player for AngularJS | JavaScript for Line of Business Applications | Scoop.it

* Videogular is developed with AngularJS and it will fit in your project like a charm.

* Videogular's directives are bindable, just try the demoand play with bindings.

* Thanks to our API you can develop your own plugins.

* Customize it with your own themes and change between them on the fly.

* Enjoy with native fullscreen support for Chrome, Firefox, Safari, iOS, Chrome for Android and Windows Phone.

* Videogular can detect mobile devices to show/hide components in case that aren't supported.

No comment yet.
Scoop.it!

Combining AngularJS with Existing (jQuery) Components

Combining AngularJS with Existing (jQuery) Components | JavaScript for Line of Business Applications | Scoop.it

A common question when looking at AngularJS for the first time is about how to combine it with existing JavaScript code and components. For jQuery UI in particular, the team around AngularJS has created the AngularUI project (http://angular-ui.github.com/) which provides an easy way to use jQuery UI with Angular.). For other frameworks - or especially for your custom DOM-manipulating code - the necessary steps might not be as obvious at the first glance.

Most existing components (especially in the jQuery-world) usually work in a different way. Without Angular, when you wanted to achieve a certain behavior, like displaying a date-picker, you would usually go with a jQuery UI extension (like 'datepicker') and use call similar to $("#someinput").datepicker({...}). This would extend a standard <input> element with an ID of someinput to be turned into a datepicker.

In this command's options, you would have usually specified a callback to be invoked whenever the user selects/changes the date in the input box. But you wouldn't do this just for a single datepicker -- no, this kind of jQuery UI-extension would be littered throughout your business code for nearly every input control in your HTML. After all, your datepickers need access to the underlying model values to restrict the input to valid ranges and to perform additional validation if necessary. This mix of business code and DOM-manipulating code is sometimes the reason for maintenance headaches of JavaScript developers.

With this in mind, you can see the conundrum: how do you take classic JavaScript code (with this mix of DOM interactions and event handlers with direct manipulation of underlying business objects) and put it into the well defined structure of AngularJS?


No comment yet.
Scoop.it!

Understanding AngularJS Directives Part 2: ngView

In a previous article I explored ng-repeat, it’s implementation, and how to create a custom repeater. In this article I’ll first delve into the inner workings of ngView and then walk through the creation of an “ngMultiView” directive. To get the most out of this article you’ll need an intermediate understanding of creating directives (via the previous article on ng-repeat and reading the the AngularJS directive guide).

Starting with AngualrJS 1.2, the ngView directive, and the $route service were moved into a separate module called ngRoute. As a result, to use routes and ngView your app must explicitly declare it as a dependency. Furthermore, the syntax for the “otherwise” statement is slightly different from older versions of AngularJS. 

No comment yet.
Scoop.it!

ngprogress-lite - Angular provider for slim progress bars

ngprogress-lite - Angular provider for slim progress bars | JavaScript for Line of Business Applications | Scoop.it

Nice looking slim progress bars provider for Angular.js applications.

It has similar API as original popular jQuery plugin (see references) to keep things as simple as possible.

The only dependency is angular.js framework.

No comment yet.
Scoop.it!

Drag and Drop File Upload with AngularJS

Drag and Drop File Upload with AngularJS | JavaScript for Line of Business Applications | Scoop.it

A reusable AngularJS directive leveraging HTML5 Drag and Drop and the FileReader API.

Directives allow you to create new HTML elements, attributes, classes, or comments that can transform the behavior of the DOM. A better way of thinking about directives is “a way to teach HTML new tricks.” In this example, you will see how to leverage directives to solve a common drag and drop problem that can be reused in the future.

No comment yet.
Scoop.it!

Variable templates for an AngularJS directive

Variable templates for an AngularJS directive | JavaScript for Line of Business Applications | Scoop.it

Sometimes web services and APIs return different data sets for the same type of object. For example, the tumblr API will return a list of posts, but each post type has different data associated with it: text posts have a title and body, while photo posts have captions and images.

Since having different components and directives for each post type doesn't make much sense (especially when they're all displayed in one stream, as on tumblr), it's beneficial to be able to conditionally load a template based on the post type of each individual post.

No comment yet.
Scoop.it!

How to create a Directive in AngularJS (simply)

How to create a Directive in AngularJS (simply) | JavaScript for Line of Business Applications | Scoop.it

When you first hear about AngularJS Directives, they appear magic in the 'omg what is going on here' way. As a newcomer to AngularJS, the idea of extending HTML with your own elements seems foreign, or a callback to IE6. Without mastering directives, you'll limit the potential of your AngularJS apps -- not cool.

It doesn't have to be this way: you can create Directives to reuse code and make templates easier for you (and future-you) to understand. You'll think of Directives as creating a DSL in HTML, and become a Wizard of unimaginable power! Ok, maybe not, but you will write easier reading code, and code that's easier to reuse.

All you need is that one example that turns the lightbulb on. Let's take an example from AngulaRails, and create a <multi-avatar> HTML element that displays a user's image, but with some requirements:

* If the user has a facebook-id, we want to use the Facebook image.

* If the user has a github username, we want to use Github's shiny avatar service.

* Otherwise, use Gravatar with the user's email.

No comment yet.
Scoop.it!

AngularJs native multi-file upload with progress

If you are reading this post you probably agree with me that AngularJs is pretty awesome. Because it’s so new, there are a number of gaps in the framework. My last post was inspired by filling a gap, and now again, I will present a directive and service I wrote because it doesn’t exist within the framework.

I am working on an application that requires users to upload files. As it’s 2013 and we are living in an asynchronous world, I wanted an intuitive UI where my users can upload files, along with some data and view upload progress. I’ve found a bunch of stuff that wraps jquery implementations, but nothing native, so, I guess I’ll build one.

Design Goals
* Native – no dependency on external frameworks
* Give the parent scope a reasonable API for managing file uploads
* Testable

As usual, I started “outside-in”, that is, I had an idea of the API I wanted to work with from the parent scope (i.e. the angular module that houses the directive) and then figured out how to build it. The directive is an element that is replaced in the DOM with the appropriate html elements.

No comment yet.
Scoop.it!

Understanding and improving AngularJS directive rendering and parsing

Understanding and improving AngularJS directive rendering and parsing | JavaScript for Line of Business Applications | Scoop.it

A while ago I noticed that AngularJS doesn’t show invalid model values bound to an <input/>

While running the example displays letters = 1 but the <input/> element remains empty.
Additionally notice that the <input/> element (due some custom CSS styling) has a “red” background to indicate that its value is invalid (since it doesn’t match the regex of ng-pattern).

In this blog post I will dig into how AngularJS handles rendering, parsing and validation and will finally provide a workaround / solution for this AngularJS bug as well as some other improvements.

In order to solve this issue we first need to understand how model values are rendered and validated.

Whenever a model value bound with ngModel changes, AngularJS uses the NgModelController#$formatters array to validate and format the model value for rendering...

No comment yet.
Scoop.it!

Angular-xeditable :: Edit-in-place for AngularJS

Angular-xeditable :: Edit-in-place for AngularJS | JavaScript for Line of Business Applications | Scoop.it

Angular-xeditable allows you to create editable elements in AngularJS project.
It is based on ideas of x-editable but was written from scratch to use power of angular and support complex forms / editable grids.

* Simple editable text
* Select local
* Select multiple
* Textarea
* Checkbox
* Validate local
* Onbefore/Onaftersave
* Editable form
* Editable table


No comment yet.
Scoop.it!

Angular Directive Examples

Angular Directive Examples | JavaScript for Line of Business Applications | Scoop.it

Directing Angular Directives
Over the last few months, I've been digging into the Angular framework. One of the things that I really like about Angular, and hope to learn to use extremely well as I progress, is their notion of a "Directive". Directives provide a means for extending both the semantic meaning and functionality of your markup. There are many different ways to implement directives, and the documentation on the angular site is still a work in progress, so I would like to share how I've used them up to this point.

The Goal: Creating a reusable donut chart and legend
First, we have to think about how we're going to get data to feed to the chart. So, I created a quick module that contains a "Product Line", which contains "Products". The plan is to be able to use a single controller and view to be able to see a donut chart and legend for both a single Product, and the full Product Line.
Each Product has a raw goods cost, shipping cost, and markup amount. The singleton that is the Product Line has a way to get aggregated data from all products, for viewing overall costs in those categories. I then created a service for my angular app to interact with this module.

No comment yet.
Scoop.it!

Using AngularJS and D3 to Create a WordCloud Directive

Using AngularJS and D3 to Create a WordCloud Directive | JavaScript for Line of Business Applications | Scoop.it

One of AngularJS’ most sophisticated and unique features is directives. Directives allow you to extend the vocabulary of HTML, such that complex DOM structures and corresponding behavior can be hidden behind a new HTML tag, attribute or a CSS class.
Here, I want to present a simple yet powerful project aiming at creating an AngularJS directive to enable an easier usage of D3 for people without deep knowledge of JavaScript. This project is based on a module that provides D3 as an AngularJS service. This service can be injected via the AngularJSinjector. It enables you to inject the D3 service e.g. into a directive and use D3 in an isolated scope instead of a global variable. As an example I used a basic implementation of the world cloud visualisation by Jason Davies to demonstrate the power of D3 in AngularJS directives.

No comment yet.
Scoop.it!

angularJS Button directive with busy indicator

angularJS Button directive with busy indicator | JavaScript for Line of Business Applications | Scoop.it

I was experimenting on creating an overall “busy” indicator for a current page. Normally, we would declare an ngClick directive if we want to implement some behavior/process when we click the button.

But if the operation takes  a long time, we have no visual clue (to the user) of what’s going on.

We want to change that! In my previous post, I used NETEYE activity indicator. This time, I will use spin.js (by the same author). What prompted me to use spin.js is that it doesn’t rely on jQuery anymore.

So how do we go about this?

No comment yet.
Scoop.it!

Create a reusable AngularJS input form component

Create a reusable AngularJS input form component | JavaScript for Line of Business Applications | Scoop.it

One of the beauty of the AngularJS framework is its ability to isolate complexity with services and directives; This is perfect for segmenting our code, create very testable components, and make them reusable. A directive, which is an anticipation of the future web components, is a piece of isolated javascript, HTML and CSS that encapsulate a specific behaviour and that you can easily reuse in various apps. Once created, a directive is simply invoked by adding it to the DOM via a HTML tag (<accordion></accordion>, or a custom attribute <div accordion></div>, or a CSS class <div class="accordion"></div> (and even as HTML comment).

No comment yet.
Scoop.it!

Creating an AngularJS Directive from one of your existing plugins/scripts

Creating an AngularJS Directive from one of your existing plugins/scripts | JavaScript for Line of Business Applications | Scoop.it

Writing scripts for your websites or web apps is often a simple process, you write your script, concatenate the file into your main scripts file and it gets pushed into the DOM. Not much to it, but when it comes to AngularJS, they believe in something slightly different...

No DOM manipulation should be carried out inside a Controller, the Controller is where most of your magic happens, a communications channel between your Model data and the browser. It can be tempting to simply whack in an existing script in there (as it'll work just fine), but this goes against Angular's principles.

So here's how to migrate one of your existing scripts or plugins across into a tightly coded AngularJS directive, this also makes code readability and reuse ultra-efficient, as Directives take the strain of repetative code out the window.

Directives are Angular's answer to Web Components 'Shadow DOM' but are compatible in all browsers (not just cutting edge HTML5 supporting ones) - bringing you the power of the future technology, today. Shadow DOM injects new content based on the element, has it's own CSS and JavaScript scope and introduces some incredible behaviour mechanisms, and this is what Directives mimic to bring you this technology today.

No comment yet.
Scoop.it!

Datatable with fully dynamic columns in angularJS

Datatable with fully dynamic columns in angularJS | JavaScript for Line of Business Applications | Scoop.it

While doing some testing for a possible new project which we want to do in angularJS I discovered that its quite hard to implement a datatable which should have fully dynamic columns which can be reordered and toggled to display or not.

Many datatable implementations have either hard-coded columns which you can’t change at all or you can’t change the order of the columns in which they should be rendered. ngTable does it like that for instance.

So, I spent a rainy sunday afternoon to implement my own version and after much poking around and some frustrating moments, I finally got it.

No comment yet.
Scoop.it!

AngularJS Directive Design Made Easy

AngularJS Directive Design Made Easy | JavaScript for Line of Business Applications | Scoop.it

Directives make our lives easier when you can reuse them without needing to read or edit the source code. Then we can forget how they work, and just remember what they do.

If you’re coming from a view-centric framework, like Backbone, you may be tempted to separate your application into view-like directive chunks. For example, if you want to display a list of users, you might create a directive that reads $scope.users and prints them all out:

<user-list/>

The user-list directive works. I mean, look how DRY it is! However, contrast it withng-repeat, which handles only the repetition. Which one could be used in more places? What if you need to display users differently in two places?

No comment yet.
Scoop.it!

How to Create a Configurable AngularJS Directive

How to Create a Configurable AngularJS Directive | JavaScript for Line of Business Applications | Scoop.it
Creating a directive with AngularJS is easy. Check out how I made one to handle errors effortlessly.

In our CampNG class, we have a section on adding validations and error messages. Having to add a span for each possible validation error is pretty tedious, so I thought I’d have a go at writing a directive to do it. One thing that was interesting about building it was making it configurable. I haven’t seen much info out there about how to do this, so I thought I’d talk about how I did it.

No comment yet.
Scoop.it!

AngularJS: Scroll Animations

AngularJS: Scroll Animations | JavaScript for Line of Business Applications | Scoop.it

Everyone has seen scroll based animations right? You know, the ones where you start scrolling down the webpage and animations start triggering around depending on how much you have scrolled. One of my favorite examples is Let’s free Congress.

Now, sometimes we want to trigger an animation, but we don’t want to make theentire page to rely on the scroll… maybe, just a little part of it. However, we can’t trigger the animation until the user is viewing the part we want to animate, or else the animation will do all its magic without no audience. How do we do it?

No comment yet.
Scoop.it!

ngTable: Simple and easy work with table on AngularJS (pagination, sorting, filtering)

This directive allow to liven your tables. It support sorting, filtering and pagination. Header row with titles and filters automatic generated on compilation step.

Examples:
* Pagination
* Sorting
* Filtering
* Cell template
* Row template
* Params in url
* Ajax
* Custom template(pagination)
* Custom filters
* Table with checkboxes


No comment yet.
Scoop.it!

The 80/20 Guide to Writing AngularJS Directives

The 80/20 Guide to Writing AngularJS Directives | JavaScript for Line of Business Applications | Scoop.it

For most of you, the reason that you’re writing directives is probably pretty straightforward, such as to integrate with existing Bootstrap modules and jQuery extensions, or to DRY up your UI. In this post, I’ll lay out the basic idea behind AngularJS directives, demonstrate what they do with roughly corresponding jQuery code, and provide you with enough knowledge to develop some pretty sophisticated directives.
At the highest level, a directive allows you to wire your custom UI components in to AngularJS’s two-way data-binding and scoping features, allowing you to define easily reusable ways for your users to view and interact with your underlying data. By default, a directive is a function that is run on every element with a particular attribute. This function takes as parameters the associated element and the AngularJS scope that this element is in. Let’s start out with an extremely simple example: setting the minimum height and width of an image while preserving its aspect ratio. There are several ways to do this, but the easiest is to make set the image as the background of a div using the following CSS...

No comment yet.
Scoop.it!

Building a Custom AngularJS Unique Value Directive

Building a Custom AngularJS Unique Value Directive | JavaScript for Line of Business Applications | Scoop.it

One of the tasks that comes up fairly frequently in application development is ensuring that a specific value is unique as a user enters it into a form. For example, you may have a user name or email that is entered by a user that you want to ensure is unique before allowing them to submit the form. There are a variety of ways to handle that type of scenario including making standard Ajax calls directly from an AngularJS controller, but if you find yourself performing this type of task over and over it may be time to consolidate your code and make a re-useable component. Enter directives – the perfect way to add “unique value” functionality into a form.

In this post I’m going to walk through a simple unique value directive and show how it can be used. Along the way I’ll also discuss a few aspects of validation in AngularJS as well.

No comment yet.
Scoop.it!

typeahead.js directive for angular.js

typeahead.js directive for angular.js | JavaScript for Line of Business Applications | Scoop.it

Some fellows at Twitter open-sourced their implementation of autocomplete.  They called it typeahead.js. Head over to their documentation pages to read more details about this awesome library. It is important that you understand the parameters/options that the library needs in order to configure it, and make it work.

In this post, I was tinkering on making an angularJS directive to wrap the typeahead.jsautocomplete library.  The end product, would look like something as shown below. Note that I am using Bootstrap 3 CSS library to style my web page...

No comment yet.
Scoop.it!

AngularJS - Perceived Performance Directive

AngularJS - Perceived Performance Directive | JavaScript for Line of Business Applications | Scoop.it

In a traditional page, measuring the page performance is quite easy; a request is made, the server responds with some HTML and the browser renders it. Done.

A lot of the rendering logic is taken care of as part of the server processing and so looking at Window Load and DOMContentReady are good indicators of page performance.

In a Single Page Application, things get trickier. The Window Load is only the beginning - that's when the JavaScript has been delivered to the browser, at which point the client-side logic - all the real work - kicks in and begins rendering the page, making API calls and setting up listeners, events, etc.

The DOM is then continuously manipulated as part of user interaction or monitoring, polling and other events. As you can see, the traditional definition of a page being 'done' doesn't apply here.

The perceived page performance is how long the user thinks the major elements of the page took to load. By definition it is highly subjective - some users may think that the page is loaded just because the initial furniture appears. But for most users this will be the parts of the page they consider most important.

No comment yet.
Scoop.it!

D3 on AngularJS

D3 on AngularJS | JavaScript for Line of Business Applications | Scoop.it

D3, the javascript library for manipulating document-based data is insanely expressive and helps bring data to life through HTML, SVG, and CSS. It has a large, growing community and there are tons of examples for what can be done with it.

Combining the power of D3 and Angular can be challenging and confusing. We constantly get asked how to integrate the two in our classes. In this post, we aim to clear the confusion and bring you the best documentation on how to integrate AngularJS and D3.

The Angular way of integrating D3 into AngularJS is by using a directive. If you’re not familiar with directives, they are Angular’s way of extending the functionality of HTML. They are, at their core functions that are executed on a DOM element that give the element functionality. All tags in AngularJS are directives. For more information, see our post about how to Build custom directives with AngularJS.

* Using d3 with dependency injection
* Creating our first basic d3 directive
* Data binding to the svg
* Handling click events
* Dynamic data over XHR
* Extending your own d3 directives


No comment yet.