Skip to content

Instantly share code, notes, and snippets.

View vseventer's full-sized avatar

Mark van Seventer vseventer

View GitHub Profile
@vseventer
vseventer / angular-upload.html
Created May 27, 2014 16:34
Upload files through a form using Angular with Kinvey.
<doctype html5>
<div class="form-group" ng-controller="UploadCtrl">
<input type="file" class="form-control" ng-file-select="onFileUpload($files)" />
<button class="btn btn-success" ng-click="saveTruck()"> <span class="glyphicon glyphicon-ok"></span>&nbsp;Update Information</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="angular-file-upload.min.js"></script>
<script src="https://da189i1jfloii.cloudfront.net/js/kinvey-angular-1.1.8.js"></script>
<script>
@vseventer
vseventer / user.js
Created March 4, 2014 17:02
Kinvey JavaScript library for Ember.js: defining users.
// Define the `User` model, and set the adapter to Kinvey.
App.User = Kinvey.User.extend({
// `Kinvey.User` extends `Kinvey.Model` and thus also provides your
// users with `acl`, `createdAt`, and `lastModifiedAt` attributes.
// In addition, the following attributes are set: `username`,
// `password`, `email`, `firstName`, `lastName`, `fullName`, and
// `isLoggedIn`. Add your own here.
dateOfBirth: DS.attr('date')
});
@vseventer
vseventer / book.js
Created March 4, 2014 16:59
Kinvey JavaScript library for Ember.js: defining models.
// Define a `Book` model, and set the adapter to Kinvey.
App.Book = Kinvey.Model.extend({
// `Kinvey.Model` provides your models with three attributes:
// `acl`, `createdAt`, and `lastModifiedAt`. Add your own here.
author: DS.attr('string'),
title : DS.attr('string')
});
App.BookAdapter = Kinvey.RESTAdapter;
@vseventer
vseventer / application.js
Created March 4, 2014 16:56
Kinvey JavaScript library for Ember.js: adding an initializer.
// Replace `App Key` and `App Secret` with your application credentials.
var kinveyOptions = {
appKey : 'App Key',
appSecret : 'App Secret',
debug : true // Enable debug mode (development only).
};
// Add the Kinvey initializer.
Ember.Application.initializer({
name : 'kinvey',
@vseventer
vseventer / index.html
Created March 4, 2014 16:51
Kinvey JavaScript library for Ember.js: loading.
...
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.4.0/ember.min.js"></script>
<script src="ember-data.js"></script>
<script src="//da189i1jfloii.cloudfront.net/js/kinvey-ember-2.0.0-beta.js"></script>
</body>
</html>
@vseventer
vseventer / gist:8342598
Created January 9, 2014 21:43
The new, easy way of defining an AngularJS controller which uses $kinvey.
app.controller('DataCtrl', ['$scope', '$kinvey', function($scope, $kinvey) {
$kinvey.DataStore.get('collection-name', 'entity-id').then(function(entity) {
$scope.entity = entity;
});
}]);
@vseventer
vseventer / gist:8342583
Last active January 2, 2016 18:19
The old way of defining an AngularJS controller which uses $kinvey. Note $scope.$apply() is required.
app.controller('DataCtrl', ['$scope', '$kinvey', function($scope, $kinvey) {
$kinvey.DataStore.get('collection-name', 'entity-id').then(function(entity) {
$scope.entity = entity;
$scope.$apply();
});
}]);
@vseventer
vseventer / gist:8342579
Last active January 2, 2016 18:19
Initialize Kinvey, then bootstrap AngularJS.
<html>
<script>
var myApp = angular.module('MyApp', ['kinvey']);
var $injector = angular.injector(['ng', 'kinvey']);
$injector.invoke(['$kinvey', function($kinvey) {
$kinvey.init({
appKey : 'App Key',
appSecret : 'App Secret'
@vseventer
vseventer / gist:8342575
Created January 9, 2014 21:41
Initialize Kinvey for use with AngularJS.
<html ng-app="MyApp">
<script>
var myApp = angular.module('MyApp', ['kinvey']);
myApp.run(function($kinvey) {
$kinvey.init({
appKey : 'App Key',
appSecret : 'App Secret'
});
});
@vseventer
vseventer / gist:8342565
Created January 9, 2014 21:40
Adding the Kinvey AngularJS library to your web app.
<script src="//da189i1jfloii.cloudfront.net/js/kinvey-angular-1.1.4.min.js"></script>