JavaScript for Li...
Follow
Find tag "directive"
261.4K views | +406 today
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...
Scoop.it!

Extending HTML with AngularJS's Directives

Extending HTML with AngularJS's Directives | JavaScript for Line of Business Applications | Scoop.it
The main thing about AngularJS is that it allows us to extend the capabilities of HTML to serve the purpose of today's dynamic webpages. In this article I will show you how you can use AngularJS's Directives to make your development faster, easier and your code more maintainable. | Difficulty: Intermediate; Length: Medium; Tags: AngularJS, JavaScript
more...
No comment yet.
Scoop.it!

ngReactGrid - A really fast Angular grid using the power of React

ngReactGrid - A really fast Angular grid using the power of React | JavaScript for Line of Business Applications | Scoop.it

ngReactGrid is an Angular directive that can be used to render an enhanced HTML table or grid of data very fast using React as the rendering engine. It is based on ng-grid and jQuery DataTables. It uses HTML tables and supports fixed column headers by default.

Jan Hesse's insight:

http://www.josebalius.com/why-i-stopped-using-ng-grid-and-rolled-my-own-with-reactjs/

more...
No comment yet.
Scoop.it!

Leaflet directive for AngularJS

Leaflet directive for AngularJS | JavaScript for Line of Business Applications | Scoop.it

This directive allows you to embed a map on your AngularJS application and interact bi-directionally with it via the AngularJS scope and the leaflet map library API. In its current state, it's not a full-featured library, although it's easy to use and extend, and a good starting point to learn to code a directive into the great AngularJS library.

more...
No comment yet.
Scoop.it!

Collection of AngularJS Directives

Collection of AngularJS Directives | JavaScript for Line of Business Applications | Scoop.it

A growing list of handy Directives.


Categories:

* $http
* bootstrap
* charts
* drag-n-drop
* filter
* form
* image
* layout
* map
* mobile
* scroll
* sort
* table
* touch
* upload

more...
No comment yet.
Scoop.it!

ion-search directive with Ionic framework

ion-search directive with Ionic framework | JavaScript for Line of Business Applications | Scoop.it

A demo of a directive which add a fancy search bar to filter data. It can filter / search from promises sources and preloaded sources. For the promises demo, I used Web SQL, so it's Chrome/Safari only compatible (but 100% compatible with the SQLite Cordova plugin :D)

more...
No comment yet.
Scoop.it!

Posting Data & AngularJS Custom Directives in an ASP.NET MVC application

Posting Data & AngularJS Custom Directives in an ASP.NET MVC application | JavaScript for Line of Business Applications | Scoop.it

In this article, we will explore how to use AngularJS to Post Data and use AngularJS Custom Directives in an ASP.NET MVC application.

So to post data, we need to simply call the save function on our resource instance. However there is a slight gotcha. The $resource object expects all the functions to post to the same URL. In MVC terms, this means posting to the same action method with different HttpGet/HttpPost/HttpPut etc attributes.

In our code, currently the HomeController uses GetTweets method to get the Data. Now Posting to a URL called GetTweets is semantically icky. So let’s update the Controller method to be called justTweetSo we will do GET, POST, PUT etc. requests to the url /Home/Tweet.

more...
No comment yet.
Scoop.it!

AngularJS Custom Directives

AngularJS Custom Directives | JavaScript for Line of Business Applications | Scoop.it

AngularJS directives are what controls the rendering of the HTML inside an AngularJS application. Examples of directives are the interpolation directive ( {{ }} ), the ng-repeat directive and ng-if directive.
It is possible to implement your own directives too. This is what AngularJS refers to as "teaching HTML new tricks".

You can implement the following types of directives:
* Element directives
* Attribute directives
* CSS class directives
* Comment directives

Of these, AngularJS recommends that you try to use element and attribute directives, and leave the CSS class and comment directives (unless absolutely necessary).
The type of a directive determines how the directive is activated. An element directive is activated when AngularJS finds a matching HTML element in the HTML template. An attribute directive is activated when AngularJS finds a matching HTML element attribute. A CSS class directive is activated when AngularJS finds a matching CSS Class. And, a comment directive is activated when AngularJS finds a matching HTML comment.

more...
No comment yet.
Scoop.it!

ngDialog.js - Modals and popups provider for Angular.js applications

Modal dialogs and popups provider for Angular.js applications.

ngDialog is small (~2Kb), has minimalistic API, highly customizable through themes and has only Angular.js as dependency.

ngDialog service provides easy to use and minimalistic API, but in the same time it's powerful enough. 

more...
No comment yet.
Scoop.it!

NgReact.js - React Components in Angular

Facebook's React library is designed to be used as a view component atop other JavaScript frameworks. NgReact is a pair of proof of concept directives that show how React can cooperate with Angular, resulting in performance gains nearly up to 70% (or, well, losses up to 450%).

more...
No comment yet.
Scoop.it!

Unit testing an AngularJS directive

Unit testing an AngularJS directive | JavaScript for Line of Business Applications | Scoop.it

In this article, i’ll detail the process to unit test the stepper directive we’ve created in the last week custom component creation article. Next week, i’ll cover how to distribute your component via GitHub and Bower.

Unit testing is the art of testing individually every smallest part of your code, which are the foundations of your apps sanity. Once correctly tested, these parts assembled together will also play nicely, as their behaviour has already been validated independently.

Unit testing helps you prevent regressions, increase quality, maintenability, and trust in your codebase, thus better team collaboration, easier refactoring… and WIN :)

Another usage is, when you get a new bug report, you add the revelant test that demo the bug, fix it in your code so the test will pass, then keep it there as a proof of reliability.

more...
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).

more...
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.

more...
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.

more...
No comment yet.
Scoop.it!

AngularJS and jQuery Dialogs

I’m using jQuery dialogs in an AngularJS application. I’ve struggled to find a way to use them that follows angular ‘best practices’.


Then I thought, what if I created a generic directive that would allow me to set the dialog options in the markup? Furthermore, what if I could register the the dialog in a service so I could inject it into a controller and open the dialog using that controller? It turns out it’s possible with a little angular black magic. Meet the jqdialog directive.

more...
No comment yet.
Scoop.it!

Why I stopped using ng-grid and rolled my own with ReactJS

Why I stopped using ng-grid and rolled my own with ReactJS | JavaScript for Line of Business Applications | Scoop.it

I get that ng-grid is based off SlickGrid and uses virtualization to not render the full data set, but I am not sure this works well with Angular and the performance issues you run into when you have 2000+ bindings on the page.

I knew I could not be happy with this project until I fixed this problem. I tried a lot things with ng-grid, using bindonce, and other suggestions but the performance gain would usually create a bug in one of the grids where I was expecting the bindings to work as usual.

At the time, I thought to myself that I should switch to ng-table. But I had written so much code already that the ng-table seemed too expensive.

That's when I decided to create a proof of concept with one of the bigger grids and render it with ReactJS.

I created an AngularJS directive called reactGrid, and tried to support ng-grid's api as much as possible (with some minor changes).

Jan Hesse's insight:

http://josebalius.github.io/ngReactGrid/

more...
No comment yet.
Scoop.it!

n3-charts: Versatile charts for AngularJS

n3-charts: Versatile charts for AngularJS | JavaScript for Line of Business Applications | Scoop.it

Built on top of D3.js and AngularJS, n3-charts.line-chart directive creates beautiful charts in AngularJS applications. It is simple and interactive.

Jan Hesse's insight:

https://github.com/n3-charts/line-chart

more...
No comment yet.
Scoop.it!

5 useful AngularJS directives, modules and services

5 useful AngularJS directives, modules and services | JavaScript for Line of Business Applications | Scoop.it

* ng-flow

* RESTAngular

* ng-table

* ui-router

* ng-csv

more...
No comment yet.
Scoop.it!

Hacking Core Directives in AngularJS

Because Angular is totally modular, you can easily replace any of its parts. Lets look at ngSrc for a case where this technique is useful...

We want to parse a list of Angular expressions from the value of ngSrc and only set src if all of them are defined.
We can use decorators to make ngSrc have this behavior.


more...
No comment yet.
Scoop.it!

Angle Brackets, Synergistic Directives

Angle Brackets, Synergistic Directives | JavaScript for Line of Business Applications | Scoop.it

Just as promised, this article will cover isolate scopes, transclusion, linking functions, compilers, directive controllers, and more.

Synergy makes Angular applications work as if magic existed. Synergy makes complex interaction feel easy, reasonable, and understandable. Synergy is what drives complex interaction into its building blocks, breaking it down into the essentials, which anyone can understand. Synergy is everywhere, synergy isn't just in code itself, but you can find it in UX, too. A synergistic application will feel more natural, easier to use, and more intuitive. You'll feel like you know the application, and often guess correctly what the next step will look like, because the application author cared about what you'd think should happen.
In Angular, synergy means being able to build componentized directives, services, and controllers, which can be reused as often as it makes sense for them to be reused. For instance, you might have a simple directive which turns on a class based on a watched scope expression, and I'd imagine that could be a pretty common directive, used everywhere in your application, to signal the state of a particular component in your code. You could have a service to aggregate keyboard shortcut handling, and have controllers, directives, and other services, register shortcuts with that service, rooting all of your keyboard shortcut handling in one nicely self-contained service.
Directives are also reusable pieces of functionality, but most often, these are associated to DOM fragments, or templates, rather than merely providing functionality. Markup is equally important in providing synergy, if not even more so. Time for me to give you a deep down dive of Angular directives and their use cases.

more...
No comment yet.
Scoop.it!

A Practical Guide to AngularJS Directives

A Practical Guide to AngularJS Directives | JavaScript for Line of Business Applications | Scoop.it

Directives are the most important components of any AngularJS application. Although AngularJS ships with wide range of directives, you will often need to create application specific directives. This tutorial will give an overview of custom directives and explain how to use them in real world Angular projects. At the end of the tutorial, I will guide you through the creation of a simple note taking app with the help of Angular directives.

Jan Hesse's insight:

follow up:

http://www.sitepoint.com/practical-guide-angularjs-directives-part-two/

more...
No comment yet.
Scoop.it!

angular-ui-foundation: AngularJS Directives for Foundation

angular-ui-foundation: AngularJS Directives for Foundation | JavaScript for Line of Business Applications | Scoop.it

Provides directives specific for using Foundation with AngularJS. 

more...
No comment yet.
Scoop.it!

Testing AngularJS directive templates with Jasmine and Karma

Testing AngularJS directive templates with Jasmine and Karma | JavaScript for Line of Business Applications | Scoop.it

In my day job, I work on appear.in, a video chat service built with AngularJS and WebRTC. Recently, our application has become more complex, and our HTML templates ended up having a lot of state in them. We could no longer just use unit testing to verify our application logic, we also needed to test the state in our templates.

For our unit testing, we landed on using Jasmine and Karma, and this has worked fairly well for us. So when we wanted to test our templates, we wanted to use the same tools.

more...
No comment yet.
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.

more...
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?


more...
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. 

more...
No comment yet.