Skip to content

Instantly share code, notes, and snippets.

View Mozartted's full-sized avatar
💭
building stuff

Chibuike Osita Mozartted

💭
building stuff
View GitHub Profile
parse_str(file_get_contents("php://input"),$post_vars); //why this ?... the post could have gotten the values without it...
$getProject->project_name = filter_var($post_vars['newProjectname'], FILTER_SANITIZE_STRING);
$getProject->due_date = trim($post_vars['newDate']);
$getProject->status = filter_var($post_vars['newTeam']);
$getProject->dept_id = filter_var($post_vars['newDeptId']);
@Mozartted
Mozartted / index.html
Created February 1, 2017 02:24
The apps index file
<!doctype html>
<html lang="en" ng-app="TodoMVC">
<head>
<title>Todo</title>
<!--All the cool css links, wait its just bootstrap-->
<link rel="stylesheet" href="styles/bootstrap.min.css">
<link rel="stylesheet" href="styles/styles.css">
<link rel="stylesheet" href="styles/base.css">
@Mozartted
Mozartted / index.js
Created February 1, 2017 14:01
Server index file -starting up the server
//the server components.
require('dotenv').load();
var express=require("express");
var mongoose=require("mongoose");
var path = require('path');
var config= require('./server/config/createdb')
var routes=require('./server/routes');
var app=express();
var port=process.env.PORT||3000;
//the route would use the express api to perform operations
//using the Todo.Controllers.js
var Todo = require('./controller/Todo.Controllers');
//create,retrieve,update, delete
module.exports=function(app){
app.post('/api/todo',Todo.Create);//create
app.delete('/api/todo/:id',Todo.Delete);//delete
app.get('/api/todo',Todo.RetrieveAll);//retrieve
@Mozartted
Mozartted / TodoController.js
Created February 1, 2017 14:23
The Todo Controller
//controller to perform several operations on Todo model...
//getting all tasks
//saving tasks
//getting completed tasks
//getting incompleted tasks
//deleting tasks
//editing tasks
var Todo=require('../models/Todo');
angular.module('TodoMVC',['ngRoute','ngResource']);
var app=angular.module('TodoMVC');
app.config(['$routeProvider',function($routeProvider){
'use strict';
var routeConfig={
controller:'TodoController',
templateUrl:'angular-stuff/html/todo.html',
resolve: {
store: function (TodoStore) {.
return TodoStore
}
app.controller('TodoController',function TodoController ($scope,$routeParams,$filter,store){
//the todo controller would be handling new additions to the
//todo list and applying these to the DB via node and $resource
'use strict';
var self=this;
store.get();
var todos = $scope.todos = store.todos;
app.factory('TodoStore',function($http,$injector){
return $http.get('/api').then(
function () {
return $injector.get('api');
},
function () {
return $injector.get('localStorage');
}
);