...decorating internal methods, so you can realize this by decorating its $httpBackend. Here a CoffeeScript [2] solution: @app.decorator '$httpBackend', ['$delegate', ($delegate) -> -> headers = arguments[4] contentType = headers?['X-Force-Content-Type...
...Restangular which you probably don't want to. [2] If you don't speak CoffeeScript, take this JavaScript: this.app.decorator('$httpBackend', ['$delegate', function($delegate) { return function() { var headers = arguments[4];
If you are using Coffeescript, it is likely to be the culprit. Since Coffeescript always returns the value of the last expression, it may return DOM nodes: # coffeescript
Solution By adding an explicit return value (e.g. return false), you can Coffeescript from returning a DOM node into Angular...
...type='button' copy-to-clipboard-button data-clipboard-text="Hello Clipboard!") Prepare your javascript (coffeescript): clipboard = new Clipboard('[copy-to-clipboard-button]') clipboard.on 'success', -> # do cool things e.g. inform user...
...even works with data-clipboard-text after the button was clicked. Here's a coffeescript snippet using bootstrap tooltips: clip.on 'error', (event) -> $button .tooltip(title: tooltipText()) .tooltip('show') .on 'hidden.bs.tooltip...
...this does not detect touch devices, but browsers.) Javascript var isTouchDevice = 'ontouchstart' in window Coffeescript isTouchDevice = 'ontouchstart' of window On the difference between the Javascript and the Coffeescript version, see...
...Beware: Coffeescript "in" is not the Javascript "in...
...text attribute specifies something available in your current scope: This is the directive, in CoffeeScript syntax: @app.directive 'simpleFormat', -> restrict: 'E' scope: true template: """ {{ line }} """ link: (scope, element, attributes) -> scope.$watch...
...property of the isolate scope to a function in the parent scope. Example: # HTML # Coffeescript @app.directive 'panel', -> scope: parentFn: '&proxy' link: (scope) -> scope.parentFn(arg1: 'first', arg2: 'second')
...in the proxy definition in the HTML, and even a combination with variables: # HTML # Coffeescript @app.directive 'panel', -> restrict: 'E' scope: parentFn: '&proxy' link: (scope) -> scope.parentFn(arg: 'the argument') ... calls parent.someFunction...
...name: "Sam" })); Whatever is in the <%...
...%> is evaluated in Javascript. You can also use CoffeeScript here: Sprockets supports two JavaScript template languages: EJS, for embedded JavaScript, and Eco, for embedded...
...CoffeeScript. Both languages use the familiar <% … %> syntax for embedding logic in templates. This allows you to e. g. write templates for Backbone views using Haml...
When CoffeeScript was added to Rails 3.1 they forgot one very important part, the ability to use it when responding to JavaScript (JS) requests! In Rails 3.1 it’s incredibly...
...easy to build your application’s JavaScript using CoffeeScript, however if you fire off an AJAX request to your application you can only write your response using regular JavaScript and...
...uses basic JavaScript, your code will run in any browser. You don't need CoffeeScript or an ES6 transpiler like Babel. A cosmetic benefit is that the module pattern works...
...that you can use. You might also want to consider using ES6 classes or CoffeeScript classes instead...
...breaking spaces or hyphens of various lengths. For this, use the ways below. Javascript, Coffeescript Use the \u escape sequence: note = '\u266A' You can use Unicode escape sequences in both...
...return true/false for objects humans would normally consider blank or present. Here is some CoffeeScript that provides _.isBlank and _.isPresent via LoDash/Underscore.js mixins: _.mixin isBlank: (object) -> switch typeof object
...isolate scopes have three different variable binding strategies, of which one is =. Example: # HTML # Coffeescript @app.directive 'panel', -> scope: evaluated: '=value' bound: '=twoway' link: -> scope.evaluated # = false scope.bound = 'foo' # Updates parent.someProperty
...makes slides be as wide as their container. You may want to use this CoffeeScript to start with: $(".slider--contents").sudoSlider auto: true # maybe turn this off when debugging your...
...Rails' to_sentence in your JavaScript application, you can use these few lines of CoffeeScript code: joinSentence = (array) -> if array.length > 1 array[0..-2].join(', ') + ', and ' + array[-1..] else array.join...
...object. Save your future self some headaches and use another name like me instead (Coffeescript chose to use _this...
twice.call(5) # => 10 Note that the syntax is subtly different from Coffeescript where you define function parameters before the arrow: (x) -> { 2 * x...
It's mixins (modules) for Coffeescript classes. Other than most homegrown approaches, this one allows you to keep using super...
The attached Coffeescript helper will let you create mouse events: $element = $('div') Trigger.mouseover($element) Trigger.mouseenter($element) Trigger.mousedown($element) Trigger.mouseup($element) Trigger.mouseout($element) Trigger.mouseleave($element) Trigger.click($element) The dispatched events are...
...sense in a project that is using jQuery anyway. Below is the polyfill in Coffeescript. It is mostly compliant with Promises A+ spec if you are using jQuery 3+: