Skip to content

Sharing object between backend and frontend in angular-fullstack env #1070

Open
@luckylooke

Description

@luckylooke

What is the best way to use same object for mongose schema and angular controler?

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var sharedObject = {
    name: String,
    info: String,
    active: Boolean
};
var MissionSchema = new Schema(sharedObject);

module.exports = mongoose.model('Mission', MissionSchema);

AND

angular.module('myApp')
  .controller('MyCtrl', function ($scope, $http, socket, sharingService) {
    var sharedObject = sharingService('myObjectSchema');

   generateForm(sharedObject);
  });

Any helpful info appreciated, thanks :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions