trycom / parse-angular-patch Goto Github PK
View Code? Open in Web Editor NEWSeamless patch for Parse JS SDK to work natively with AngularJS
Seamless patch for Parse JS SDK to work natively with AngularJS
This commit breaks the demo:
[Error] TypeError: undefined is not an object (evaluating 'Parse[currentClass][method]')
(anonymous function) (parse-angular.js, line 91)
forEach ([native code], line 0)
(anonymous function) (parse-angular.js, line 89)
invoke (angular.js, line 3704)
(anonymous function) (angular.js, line 3550)
forEach ([native code], line 0)
forEach (angular.js, line 302)
createInjector (angular.js, line 3550)
doBootstrap (angular.js, line 1298)
bootstrap (angular.js, line 1313)
(anonymous function) (localhost, line 124)
fire (jquery.js, line 2913)
fireWith (jquery.js, line 3025)
ready (jquery.js, line 398)
completed (jquery.js, line 93)
Which versions does this patch work for? More specifically does it work with the latest version 1.4.2? Also what about Angular versions? Does this work with 1.3.x and 1.4.x?
parse-angular-patch
wraps Parse.Promise
into $q
style promises from what I understand.
However, it does not appear that .finally()
can be used and .always()
must be used instead. This behavior seems inconsistent with the documentation and is a point of confusion. Any idea on how to patch this as well?
Any chance you could include a bower version tag for future releases? I'm currently forced pull the latest using "parse-angular-patch": "*".
The latest commit broke a deploy script I use as the app was using an older SDK which didn't include the new config functionality.
Hi,
any plans for an official release? And maybe an updated parse-angular-demo?
Thanks,
balazs
Hello,
Let's say you have a parse class called "Company", and that class has a pointer to another class called "Product". After you received a Company object from your query, you could retrieve the product name like this:
var productName = result.get("product").get("name");
This works as long as I make sure and call query.include("product") in my query.
However, as you know, angular binding doesn't work well with backbone-style models. This is where your patch comes in! But does your patch work when binding to nested objects, like this?
{{company.product.name}}
So far I have managed to perform a query, auto generate getter/setters, expose the value of my object using the notation {{myObj.getName()}}.
This all works well but I would like to be able to edit the values of myObj, and so far I have not figured out an elegant way to do so.
I would imagine, if the attribute of the getter/setter was exposed, I would be able to use the ng-model notation ng-model="myObj.name".
This would of course not perfom any updates on the database side of parse but it would be rather trivial to implement a saveState() method, to persist the current state of myObj.
I feel like I am missing something and hope that you can point me in the right direction.
The first line should read
bower install parse
before 'bower install parse-angular-patch`
When I try to create a collection like this, I get an empty constructor which means that I don't get access to any of standard parse class methods. The problem is that the constructor doesn't seem to be getting copied:
angular.module('doctaApp')
.service('Plans', function Plans(AppointmentFormModel) {
// AngularJS will instantiate a singleton by calling "new" on this function
var Appointment = Parse.Object.extend({
className: 'Appointment',
attrs: AppointmentFormModel
});
var AppointmentsCollection = Parse.Collection.extend({
model: Appointment
});
var appointments = new AppointmentsCollection();
console.log(appointments);
});
console output:
child
_byCid: Object
_byId: Object
length: 0
models: Array[0]
proto: EmptyConstructor
constructor: function (){ parent.apply(this, arguments); }
model: function (){ parent.apply(this, arguments); }
proto: Object
This lib will be updated to work with parse 1.7.x ?
I have a new project to start and am thinking of just going straight to angular 2. I would like to use parse, would this be an option here?
Can you add instructions on where to put this. I saw in your demo, its nested pretty far on parse-angular-demo/client/app/scripts/services/ParseServices.js but I'm modifying exported code from appgyvers steroids.js and they have a different folder layout
I have been trying to debug this for hours and hope that you have an idea of what is going on.
I have a Controller that starts off by fetching all my Guard objects and add the array of objects to the scope:
ParseService.Guards.fetchAll(function(guards) {
$scope.data = guards;
...
// data is used to setup a ngTable
}
The data is iterated using ng-repeat and the data is shown using getters, all good.
The problem occurs when I try to edit one of the elements with the following code:
$scope.formData = {};
$scope.performingEdit = false;
$scope.edit = function(guard) {
console.info('edit');
$scope.formData.name = guard.getName();
$scope.formData.guardId = guard.getGuardId();
$scope.performingEdit = true;
}
$scope.save = function(guard) {
if (guard) {
// This works and updates the UI as expected, no problems
guard.set($scope.formData);
// The updated guard msg is shown, followed by RangeError: Maximum call stack size exceeded when updating object
guard.save(null, {
success : function(guard) {
console.info('updated guard');
},
error : function(guard, error) {
console.log(error.code);
console.log(error);
}
});
}
$scope.performingEdit = false;
}
As stated in the comment, the object is correctly updated, however just after, the stack size error is bombarding the console.
Have run a lot of trial and error without being able to pinpoint the problem.
Invoking the edit a second time after seeing the error output results in a similar error complaining about isFunction instead:
RangeError: Maximum call stack size exceeded
at isFunction (http://localhost:8000/app/lib/angular/angular.js)
...
Sorry in advance if the problem is due to my lack of experience/understanding.
RangeError: Maximum call stack size exceeded
at Object.toString (native)
at isArray (http://localhost:8000/app/lib/angular/angular.js:595:19)
at copy (http://localhost:8000/app/lib/angular/angular.js:858:9)
at copy (http://localhost:8000/app/lib/angular/angular.js:852:23)
at copy (http://localhost:8000/app/lib/angular/angular.js:869:28)
at copy (http://localhost:8000/app/lib/angular/angular.js:852:23)
at copy (http://localhost:8000/app/lib/angular/angular.js:869:28)
at copy (http://localhost:8000/app/lib/angular/angular.js:852:23)
at copy (http://localhost:8000/app/lib/angular/angular.js:869:28)
at copy (http://localhost:8000/app/lib/angular/angular.js:852:23) angular.js:9505
(anonymous function) angular.js:9505
(anonymous function) angular.js:6947
Scope.$digest angular.js:11944
(anonymous function) angular.js:12107
completeOutstandingRequest angular.js:4191
(anonymous function) angular.js:4492
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.0-beta.1/$rootScope/infdig?p0=10&p1=%5B%5D angular.js:78
(anonymous function) angular.js:78
Scope.$digest angular.js:11964
(anonymous function) angular.js:12107
completeOutstandingRequest angular.js:4191
(anonymous function)
Has anyone gone through this? Is there a fix?
I just installed parse-angular-patch from bower. I get the following error in the browser console as soon is the page is loaded:
Uncaught TypeError: Cannot read property 'prototype' of undefined`
(anonymous function) @ parse-angular.js:66
(anonymous function) @ parse-angular.js:64
I believe that 'prototype' of undefined refers to Parse[currentClass].prototype[method]
:
currentProtoMethods.forEach(function(method) { << LINE 64
var origMethod = Parse[currentClass].prototype[method]; << LINE 66
// Overwrite original function by wrapping it with $q
Parse[currentClass].prototype[method] = function() {
return origMethod.apply(this, arguments)
.then(function(data) {
var defer = $q.defer();
defer.resolve(data);
return defer.promise;
}, function(err) {
var defer = $q.defer();
defer.reject(err);
return defer.promise;
});
};
});
I used src version of parse-angular-patch to get the line number for the error, but it happens on dist version too. This is my configuration... This is also the order that I am importing the scripts in HTML:
parse 1.6.9
angular 1.4.8
parse-angular-patch 0.1.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.