I'm creating a meteor app, using angular templates, and have just deployed it to my server using Meteor-Up. It runs fine on my localhost however on the server I'm receiving the following:
Argument 'HomeCtrl' is not a function, got undefined
My code is (with some replaced with ...):
homeCtrl.js
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import { Controller } from 'angular-ecmascript/module-helpers';
import { Projects } from '/lib/collections';
import faker from 'faker';
export default class HomeCtrl extends Controller {
constructor() {
super(...arguments);
this.helpers({
...
});
}
...
}
app.js
import angularMeteor from 'angular-meteor';
import 'angular-sanitize';
import 'angular-ui-router';
import angular from 'angular';
import Loader from 'angular-ecmascript/module-loader';
import HomeCtrl from '../controllers/homeCtrl'
import WizardCtrl from '../controllers/wizardCtrl'
import RoutesConfig from '../routes';
const App = 'appName';
angular.module(App, [angularMeteor, 'ui.router']);
new Loader(App)
.load(HomeCtrl)
.load(WizardCtrl)
.load(RoutesConfig);
routes.js
import { Config } from 'angular-ecmascript/module-helpers';
export default class RoutesConfig extends Config {
configure() {
this.$stateProvider
.state('home', {
url: '/',
templateUrl: 'client/templates/home.html',
controller: 'HomeCtrl as home'
})
...
this.$urlRouterProvider.otherwise('/');
}
}
RoutesConfig.$inject = ['$stateProvider', '$urlRouterProvider'];
mup.js
module.exports = {
servers: {
one: {
host: '...',
username: '...',
// pem:
password: '...'
// or leave blank for authenticate from ssh-agent
}
},
"setupMongo": false,
meteor: {
name: 'app-name',
path: '../',
servers: {
one: {}
},
buildOptions: {
serverOnly: true,
},
env: {
ROOT_URL: '...',
MONGO_URL: '...'
},
dockerImage: 'abernix/meteord:base',
deployCheckWaitTime: 60
},
};
Is there anything I've missed in deploying or something wrong with the code?
I ended up just reverting back to using standard controller functions rather than using ES6 classes. So the above HomeCtrl
would become:
var app = angular.module('home-module', []);
app.controller('homeCtrl', ['$scope', function($scope){
$scope.helpers({
...
});
...
}]);
You still need to import it in app.js, however you don't need to load it with the loader.