How to improve Angular performance by disabling debugging

Angular gives elements classes such as ng-scope and ng-isolate-scope to help tools such as Batarang and Protractor retrieve debugging information. In production, these are unnecessary, and can be disabled to speed up your client-side application. This is how you disable debugging information in Angular: myApp.config(['$compileProvider', function ($compileProvider) { $compileProvider.debugInfoEnabled(false); }]);

Disable “pull to refresh” in Chrome for Android

In mobile Chrome, pulling the top of the page will reload it. Although it’s a convenient UI pattern, it might get in the way if you are trying to implement gestures in your app. After careful observation, I have come up with a simple solution. AngularJS I have successfully disabled “pull to reload” with this […]

How to get a reference to a CodeMirror instance

If you want to access a CodeMirror instance, perhaps because it was created programmatically, or by a module you don’t control, you can access it like this: //Get a reference to the CodeMirror editor var editor = $(‘.CodeMirror’)[0].CodeMirror; //You can then use it as you wish editor.setValue(‘lorem ipsum yada yada’); editor.replaceSelection(‘this is a test’); In […]

Drag and drop image upload directive for Angular.js

While converting an application of mine to Angular.js, I could not come up with a reasonable way to support drag and drop uploads, so I have created my own. Browser support As with everything that is enjoyable on the web, this will only work in IE10+, Chrome and Firefox. This is because you will need […]

Using angular.js with Tastypie for Django

The following angular.js service will allow you to consume a standard TastyPie REST API. As you may know, TastyPie returns its JSON objects a bit differently from what angular expects, so this service fixes it. This example assumes that you have always_return_data=True in your resource. This is the resource I used with this example: class […]