Giter Club home page Giter Club logo

angularjs-mongolab's Introduction

#angularjs-mongolab

Introduction

This repository hosts a Mongolab $resource adapter for AngularJS.

This is a small wrapper around the AngularJS $resource that makes setting up and working with MongoLab easy. It significient reduces the amount of boilerplate code one needs to write when interacting with MongoDB / MongoLab (especially around URLs handling, resource objects creation and identifiers handling).

Examples

To see it in action check this jsFiddle: (http://jsfiddle.net/pkozlowski_opensource/3EPjK/2/)

Alternatively you might have a look at the example in this repository.

Usage instructions

Firstly you need to include both ngResource module and the mongolab.js script from this repository (see examples above for the exact URLs). Then, you need to configure 2 parameters:

  • MongoLab key
  • database name

Configuration parameters needs to be specified as constants on an application's module:

var app = angular.module('app', ['mongolabResource']);

app.constant('API_KEY', '[your MongoLab key here]');
app.constant('DB_NAME', 'angularjs');

Then, creating new resources is very, very easy and boils down to calling $mongolabResource with a MongoDB collection name:

app.factory('Project', function ($mongolabResource) {
  return $mongolabResource('projects');
});

As soon as the above is done you are ready to inject and use a freshly created resource in your services and controllers:

app.controller('AppController', function ($scope, Project) {
  $scope.projects = Project.query();
});

angularjs-mongolab's People

Contributors

pkozlowski-opensource avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.