angular-parse icon indicating copy to clipboard operation
angular-parse copied to clipboard

Remove dependency on CoffeeScript

Open sarbogast opened this issue 12 years ago • 6 comments

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?

sarbogast avatar Apr 11 '13 14:04 sarbogast

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

jimrhoskins avatar Apr 11 '13 15:04 jimrhoskins

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;
});

RaphiePS avatar May 08 '13 01:05 RaphiePS

This latest code snippet (using angular.copy) should be added to the JavaScript part of the Defining Models section in the README.

steren avatar Oct 03 '13 20:10 steren

@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;

});

steren avatar Oct 20 '13 21:10 steren

Hi all, just wondering if there is solution to this? I would love to try this out, but don't write coffee script.

karlcampbell avatar Nov 05 '13 18:11 karlcampbell

@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.

steren avatar Feb 05 '14 09:02 steren