background preloader

Directives

Facebook Twitter

Angularjs - Injecting service to Directive. How to stop Angular to reload when address changes. Can angularjs routes have default parameter values. A plugin based architecture for AngularJS apps. Angularjs - refresh when clicked on link with actual url. Which function is called each time url changes in AngularJS. Angularjs - Evaluating Custom Directive after jQuery replaceWith. $watch is not working when model is updated in scope.$apply in directive. $watch is not working when model is updated in scope.$apply in directive.

Lazy Loading Image With AngularJS. Insert HTML into view using AngularJS. How/when to use ng-click to call a route. Levelling Up With AngularJS: Building a Reusable Click to Edit Directive · Icelab · an Australian design studio. In my last article about AngularJS, I shared how easy it was to build a simple “click to edit” field, and along the way introduced some of Angular’s core concepts: controllers, expressions & two-way bindings between your markup and the controller’s scope.

Levelling Up With AngularJS: Building a Reusable Click to Edit Directive · Icelab · an Australian design studio

This was a nice introduction, but the resulting code has a shortfall: it’s not easily reusable. For something that behaves as a form field, you want the ability to sprinkle it across your pages wherever you like. This is where directives come in. Spurred on by Max’s recent foray into data-backed directives, I’ll now take the next steps and turn this click to edit example into a reusable Angular directive. If you’ve sprinkled Angular into your apps at all, you’ve already worked with its built-in directives, things like ng-model, ng-repeat and even ng-controller and ng-app. Here’s how we’d want a click to edit directive to look in practice: app = angular.module("formDemo", []); Let’s break this down a little. Location - Redirect using AngularJS.

Capturing Document-Click Events With AngularJS. Angular directives for Twitter's Bootstrap. The $uibPosition service provides a set of DOM utilities used internally to absolute-position an element in relation to another element (tooltips, popovers, typeaheads etc...). getRawNode(element) Takes a jQuery/jqLite element and converts it to a raw DOM element. parameters element(Type: object) - The element to convert. returns (Type: element) - A raw DOM element. parseStyle(element) Parses a numeric style value to a number.

Angular directives for Twitter's Bootstrap

Value(Type: string) - The style value to parse. (Type: number) - The numeric value of the style property. offsetParent(element) Gets the closest positioned ancestor. element(Type: element) - The element to get the offset parent for. (Type: element) - The closest positioned ancestor. scrollbarWidth(isBody) Calculates the browser scrollbar width and caches the result for future calls. Share data with its parent passing var through attr. Share data between directives and parent scopes.