Skip to content

MEAN stack with Sails.js = Mongodb, Sails.js(Express.js), Angular.js(1.5+) and NodeJS

Notifications You must be signed in to change notification settings

kazeidesign/Mean-Sails-Stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MEAN-Sails-stack

MEAN stack with Sails.js = MongoDB, Sails.js(Express.js), Angular.js 1.5+ and Node.js.

Ready to use

This app is ready to use. Clone this repository git clone https://github.com/kazeidesign/Mean-Sails-Stack.git in your server.

Run cd Mean-Sails-Stack/ && npm install && sails lift.

/!\ At the first sails lift, wait less than one minute for the automatical bower install.

Look in your browser at localhost:1337. Your Sails.js app is ready and you can use Angular.js.

Getting Started

Needed

Node.js: version 4.4.4 LTS or later

Sails.js: version 0.12.3 or later

MongoDB: version 2.4.0 or later

Angular.js: version 1.5.5 or later

Grunt-sass: version 1.2.0 or later

Angular-Resource-Sails: version 1.2.2

Angular-Material: version 1.1.0 or later

Html5-boilerplate: version 5.3.0 or later


CRUD between AngularJS and SailsJS

angular.module('myApp.view1', ['ngRoute', 'sailsResource'])

.config(['$routeProvider', function($routeProvider) {
  $routeProvider
  .when('/view1', {
    templateUrl: 'view1/view1.html',
    controller: 'View1Ctrl as task'
  });
}])

.controller('View1Ctrl', function ($rootScope, sailsResource) {
  var self = this;
  var item = sailsResource('Item');
  
  this.itemResource = item;
  this.itemForm = new item();
  this.itemTypes = item.query();

  this.add = function () {
    self.itemForm.$save(function (newItem) {
      self.itemTypes.push(newItem);
    });
    self.itemForm = new item();
  };

  this.cancel = function () {
    self.itemForm = new item();
  };
  
  this.deleteItem = function (item) {
    item.$delete();
  };
  
  this.editItem = function (item) {
    item.$editing = true;
  };
  
  this.saveItem = function (item) {
    item.$save();
    item.$editing = false;
  };
  
  this.checkItemCompleted = function (item){
    item.status = "completed";
    item.$save();
  };
  
  this.checkItemToDo = function (item){
    item.status = "To do";
    item.$save();
  };
  
  this.causeError = function () { 
    item.notFound(
      function (response) {
      },
      function (response) {
        self.error = response.statusCode;
      });
  };
  
  $rootScope.$on('$sailsResourceCreated', function () {
    self.created++;
  });
  
  $rootScope.$on('$sailsResourceUpdated', function () {
    self.updated++;
  });
  
  $rootScope.$on('$sailsResourceDestroyed', function () {
    self.destroyed++;
  });
})

Example

To do



Means-To-Do:
http://kazeidesign.github.io/Means-To-Do/

API Reference

Sails.JS REST

Angular Sails wraps the native sails.js REST functions. For further information check out the sails docs and Mike's Screencast

Native socket functions

The sails service is nothing more like the native socket.io object!

Enjoy!

KazeiDesign


To do

About

MEAN stack with Sails.js = Mongodb, Sails.js(Express.js), Angular.js(1.5+) and NodeJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published