AngularJS Error: [ng:areq] loginController is not a function

前端之家收集整理的这篇文章主要介绍了AngularJS Error: [ng:areq] loginController is not a function前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

场景: AngularJS做 登录页面,单独 引 JQuery 和 AngularJS文件

webapp/@H_502_4@
|---lib/@H_502_4@
|------angular@H_502_4@/@H_502_4@
|---------angular@H_502_4@.min.js@H_502_4@
|------jquery/@H_502_4@
jquery@H_502_4@.min.js@H_502_4@
|----------@H_502_4@login.html@H_502_4@@H_502_4@

|----------l@H_502_4@ogin.js@H_502_4@@H_502_4@@H_502_4@@H_502_4@
@H_502_4@@H_502_4@

l@H_502_4@ogin.js 内容如下:@H_502_4@

function loginController($scope,$http,$log){@H_502_4@@H_502_4@

$scope.login = function(){@H_502_4@@H_502_4@

if(!$scope.userCode || !$scope.password){@H_502_4@@H_502_4@

return;@H_502_4@@H_502_4@

}
@H_502_4@@H_502_4@

var userInfo = {userCode :$scope.userCode,password:$scope.password@H_502_4@@H_502_4@@H_502_4@@H_502_4@};@H_502_4@@H_502_4@

$http.post("userLogin",sans-serif; font-size:16px; line-height:25.92px; text-indent:32px">userInfo@H_502_4@).success(function(){@H_502_4@@H_502_4@

... ...@H_502_4@@H_502_4@

});@H_502_4@@H_502_4@

}@H_502_4@@H_502_4@

}@H_502_4@@H_502_4@


@H_502_4@@H_502_4@

解决方法一:将 js 文件名称修改为 login-ctrl.js@H_502_4@@H_502_4@

解决方法二:@H_502_4@@H_502_4@

在login.js文件顶部 添加@H_502_4@@H_502_4@

angular.module('login',[]);@H_502_4@@H_502_4@

angular.module('login').controller('loginController',sans-serif; font-size:16px; line-height:25.92px; text-indent:32px">loginController@H_502_4@);@H_502_4@@H_502_4@ @H_502_4@@H_502_4@

原文链接:https://www.f2er.com/angularjs/149004.html

猜你在找的Angularjs相关文章