This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simple employee factory using Restangular | |
innitApp.factory('Employee',function(Restangular){ | |
var _Employees = Restangular.all('employee') | |
return { | |
find : function(query){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appRootState = { | |
name: 'app', | |
url: '/', | |
templateUrl : '/templates/innit.app.home.html' | |
} | |
var employeesRoot = { | |
name: 'employees', | |
url: '/employees', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resolutionSystem = angular | |
.module('resolutionSystem', ['ui.router']) | |
.controller('createCaseCtrl', function($scope,Cases){ | |
//call this from your button | |
$scope.saveNewCase = function(){} | |
Cases.createNew($kase).then(function(_savedCase){ | |
console.log(_savedCase) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Global adapter config | |
* | |
* The `adapters` configuration object lets you create different global "saved settings" | |
* that you can mix and match in your models. The `default` option indicates which | |
* "saved setting" should be used if a model doesn't have an adapter specified. | |
* | |
* Keep in mind that options you define directly in your model definitions | |
* will override these settings. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* parseWhereParam | |
* | |
* @param {Object} allParams [result of calling req.params.all()] | |
* @return {Object} the WHERE criteria object | |
*/ | |
function parseWhereParam( allParams ) { | |
var where = req.param('where'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//factory syntax | |
angular.factory('myModelThingy',function($http){ | |
//private vars | |
var _someThings = [] | |
var _someOtherThings = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('fooCtrl',function(FooFactory){ | |
$scope.foos1 = FooFactory.getFoos(); | |
//or | |
FooFactory.getFoosButDontHandlePromise().then(function(foos){ | |
$scope.foos2 = foos; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api : function(req,res){ | |
var _modelKeys = Object.keys(sails.models) | |
var _models = [] | |
async.forEach(_modelKeys,function(key,done){ | |
var _model = { | |
_model : key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Employee | |
* | |
* @module :: Model | |
* @description :: A short summary of how this model works and what it represents. | |
* @docs :: http://sailsjs.org/#!documentation/models | |
*/ | |
var uuid = require('node-uuid') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var querystring = require('querystring') | |
var url = require('url'); | |
//pointless async function | |
function doAsyncMath(param1,param2,callback){ | |