JavaScript Using Angular Controllers with prototype in angular controller,angular use controller from another module

my question is really simple.

It is possible use Angular Controllers with prototype?

'use strict';
var EventController = function(scope, EventModel) {
    this.scope      = scope;
    this.EventModel = EventModel;
};

EventController.prototype = {
    create: function() {
        this.scope.create = function() {
            this.EventModel.Model.insert()
                .then(function(result) {

                });
        };
    },

    retrieve: function() {
        var that = this;

        this.EventModel.Model.find()
            .then(function(result) {
                that.scope.events = result;

            });
    },

    retrieveOne: function(id) {
        this.EventModel.Model.findOne(id)
            .then(function(result) {
                console.log(result);

            });
    },

    update: function() {
        this.EventModel.Model.update()
            .then(function(result) {

            });
    },

    delete: function() {
        this.EventModel.Model.remove()
            .then(function(result) {

            });
    }
};

module.exports = function(adminApp) {
    adminApp
        .controller('EventController', ['$scope', 'EventModel', function(scope, EventModel) {
            return new EventController(scope, EventModel);

        }]);
};

I'm using Browserify, that's why i have this module.exports in the final.

I would love to use controllers that way and get the methods as if it were the name of the objects in the prototype.

There is any way that i can do that?

Answer:1

I have a little FTP script which basically transfer an entire directory tree (by walking it with fs.readdir) to an FTP server one file at a time (I have to do some analysis on each file as it's ...

I have a little FTP script which basically transfer an entire directory tree (by walking it with fs.readdir) to an FTP server one file at a time (I have to do some analysis on each file as it's ...

  1. node make synchronous http request
  2. node make synchronous query
  3. make node js synchronous
  4. node make function synchronous
  5. node make promise synchronous
  6. make foreach synchronous node js
  7. make request synchronous node js
  8. make node js code synchronous
  9. node make callback synchronous
  10. make function synchronous node js
  11. make for loop synchronous node js
  12. node make asynchronous call synchronous

In my entity framework model (from oracle) I have a table that contains the following Column Now. I use an asp.net webforms datagrid to view the data. At one stage the value in this column is ...

In my entity framework model (from oracle) I have a table that contains the following Column Now. I use an asp.net webforms datagrid to view the data. At one stage the value in this column is ...

How would I make a sticky nav bar without using jQuery? I want to do something like: if (scrollheight == x) navbar.addclass "sticky"

How would I make a sticky nav bar without using jQuery? I want to do something like: if (scrollheight == x) navbar.addclass "sticky"

The following code reads a file and turned each line into array items: fs.readFile('en.txt', 'utf8', function (err, data) { if (err) { return console.log(err) } enStrings = data.split(/[\r\...

The following code reads a file and turned each line into array items: fs.readFile('en.txt', 'utf8', function (err, data) { if (err) { return console.log(err) } enStrings = data.split(/[\r\...

  1. javascript split extra element