paradox41/ng-chartist.js — pull request #17 by stranbird (2014-11-28 15:39:35+00:00)
Title: Avoid initializing the chart for twice

1. If a variable is watched, the callback will be called on the first event loop even if the variable is already initialized. There is not point to create a new chart anyway.
2. `detach()` is a method of optionsProvider, which is push into the event queue and assigned later.

// Using event loop for first draw to make it possible to register event listeners in the same call stack where
// the chart was created.
setTimeout(function() {
this.optionsProvider = Chartist.optionsProvider({}, this.options, this.responsiveOptions, this.eventEmitter);
this.createChart(this.optionsProvider.currentOptions);
}.bind(this), 0);

so at this moment, access of `optionsProvider` returns undefined, which successively raise a `Cannot read property 'removeMediaQueryListeners' of undefined` error when we call `detach`.
Stop to call `detach()` here fixes it.