Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fis3-angular-demo]Argument 'CualUserController' is not a function, got undefined #43

Open
yinwer81 opened this issue Mar 9, 2016 · 1 comment

Comments

@yinwer81
Copy link

yinwer81 commented Mar 9, 2016

Error: [ng:areq] Argument 'CualUserController' is not a function, got undefined
http://errors.angularjs.org/1.3.20/ng/areq?p0=CualUserController&p1=not%20aNaNunction%2C%20got%20undefined
at http://127.0.0.1:8080/statics/bower_components/angular/angular.js:63:12
at assertArg (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:1590:11)
at assertArgFn (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:1600:3)
at http://127.0.0.1:8080/statics/bower_components/angular/angular.js:8493:9
at http://127.0.0.1:8080/statics/bower_components/angular/angular.js:7661:34
at forEach (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:334:20)
at nodeLinkFn (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:7648:11)
at compositeLinkFn (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:7140:13)
at publicLinkFn (http://127.0.0.1:8080/statics/bower_components/angular/angular.js:7019:30)
at http://127.0.0.1:8080/statics/bower_components/ui-router/release/angular-ui-router.js:4089:9(anonymous function) @ angular.js:11706
angular.js:1590 Uncaught Error: [ng:areq] Argument 'fn' is not a function, got Object
http://errors.angularjs.org/1.3.20/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Object

我在fis3-angular-demo的modules/pages下,新增一个cualusers模块。

cualuser.js

module.exports = { url: '/cualusers', template: __inline('./cualusers.html'), //注意如果开启压缩,应采取此方式注入对象,否则压缩后将找不到 controller : ["$scope","$injector",function($scope, $injector) { //支持异步加载controller require.async('/modules/pages/cualusers/cualusers.async.js', function(ctrl) { $injector.invoke(ctrl, this, {'$scope': $scope}); }); }] };

cualuser.html

`


...

`

cualusers.async.js

`angular.module('xxx').controller('CualUserController', function($scope, $http) {
$scope.users = [];

$http.get('exingcai/cualuser').success(function (data, status, headers, config) {
    $scope.users = data;
}).error(function (data, status, headers, config) {
    $scope.errorMessage = "Can't retrieve cualuser list!";
});`

});

@zhangtao07
Copy link
Member

尽量别用异步加载,在 angular里面显得有点另类。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants