Remove dependency on CoffeeScript
I love what you have done but if I understand correctly what is said in your README, there is a dependency on CoffeeScript. I'm not really fan of the idea to learn and integrate CoffeeScript in the middle of AngularJS and Parse. Do you plan to implement the Javascript equivalent of what's possible with CoffeeScript anytime soon?
I may. The only thing that needs to be added is an extend method for the classes, because it currently uses CoffeeScript's class and extend syntax. Otherwise it's JavaScript compatible. Hopefully I can find time to implement it
I too would love to be able to use this with vanilla JS. Perhaps the syntax could look something like: var Car = new ParseModel("Car", ["make", "model", "year"]);
In the meantime, this works fairly well:
app.factory("Car", function(Parse) {
var Car = angular.copy(Parse.Model);
Car.configure("Car", "make", "model", "year");
return Car;
});
This latest code snippet (using angular.copy) should be added to the JavaScript part of the Defining Models section in the README.
@RaphiePS actually, using angular.copy() is not working for me with multiple Parse models. It seems that angular's copy mechanism is not similar to what coffeescript is expecting to extend classes. (the Car name attribute is still Model).
Using the exact code generated by coffeescript is working. But very ugly.
app.factory('Car', function (Parse) {
var __extends = function(child, parent) { for (var key in parent) { if ({}.hasOwnProperty.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
var Car = function() {
return Car.__super__.constructor.apply(this, arguments);
}
__extends(Car, Parse.Model);
Car.configure( 'Car', "make", "model", "year");
return Car;
});
Hi all, just wondering if there is solution to this? I would love to try this out, but don't write coffee script.
@karlcampbell you can try without CoffeeScript, the library is in JavaScript, only its sources are in CoffeeScript.
I am using angular-parse with a JavaScript application. As I said in my previous post, I needed to copy CoffeeScript's extend method.