参数 'HomeCtrl' 不是函数,在使用 Meteor-Up 部署后未定义
Argument 'HomeCtrl' is not a function, got undefined after deploying with Meteor-Up
我正在使用 angular 模板创建一个流星应用程序,并且刚刚使用 Meteor-Up 将其部署到我的服务器。它在我的本地主机上运行良好,但在服务器上我收到以下信息:
Argument 'HomeCtrl' is not a function, got undefined
我的代码是(部分替换为...):
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
},
};
我在部署过程中是否遗漏了什么或代码有什么问题?
我最终只是恢复到使用标准控制器功能而不是使用 ES6 类。所以上面的 HomeCtrl
会变成:
var app = angular.module('home-module', []);
app.controller('homeCtrl', ['$scope', function($scope){
$scope.helpers({
...
});
...
}]);
您仍然需要在 app.js 中导入它,但是您不需要使用加载器加载它。
我正在使用 angular 模板创建一个流星应用程序,并且刚刚使用 Meteor-Up 将其部署到我的服务器。它在我的本地主机上运行良好,但在服务器上我收到以下信息:
Argument 'HomeCtrl' is not a function, got undefined
我的代码是(部分替换为...):
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
},
};
我在部署过程中是否遗漏了什么或代码有什么问题?
我最终只是恢复到使用标准控制器功能而不是使用 ES6 类。所以上面的 HomeCtrl
会变成:
var app = angular.module('home-module', []);
app.controller('homeCtrl', ['$scope', function($scope){
$scope.helpers({
...
});
...
}]);
您仍然需要在 app.js 中导入它,但是您不需要使用加载器加载它。