Skip to content

Instantly share code, notes, and snippets.

View Spittal's full-sized avatar

Jamie Spittal Spittal

View GitHub Profile
public updateAvatar(file: File): Observable<any> {
return Observable.create((observer) => {
let formData: FormData = new FormData(),
xhr: XMLHttpRequest = new XMLHttpRequest();
formData.append('avatar', file, file.name);
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
@Spittal
Spittal / disabled-if-directive.js
Last active August 29, 2015 14:06
Disabled If Expression Directive for AngularJS
.directive('disabledIf', disabledIf);
function disabledIf() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var expr = attrs.disabledIf;
scope.$watch(expr, function(val) {
if (val) {