AngularJS错误:在声明我的控制器时得到ng:areq错误参数

AngularJS Error: Getting ng:areq Bad Argument in declaring my controller

本文关键字:错误 ng 参数 areq 控制器 声明 我的 AngularJS      更新时间:2023-09-26

我真的是Angular的新手,我还没能找到解决我试图使用的控制器出现的"Bad Argument"错误的方法。我不确定它是否完全是其他东西,也不确定我是如何定义控制器本身的。

提前感谢您的反馈!

JS

app.controller('questionCtrl', ['$http', '$scope', function($http, $scope) {
            console.log('question posting is ready');
            var questionText = $('input[id="qASectionHead"]').val();
            var businessIdNo = localStorage.getItem('vm.id');
            console.log(businessIdNo);
            $scope.askButton = function() {
                console.log('ask has been clicked')
                console.log('The user has typed: ' + questionText);
                $http({
                    url: 'url',
                    method: 'POST',
                    data: {
                        question_text: questionText,
                        business_id: businessIdNo,
                    },
                    headers: {
                        'Authorization': 'token'
                    },
                }).success(function(data) {
                    console.log(data);
                    });
                  };
                }]);

HTML

              <div id="qASectionContain" ng-controller="questionCtrl">
            <input id="qASectionHead" placeholder="ask this business a question">
              <button ng-click="askButton()">
               ask
              </button>

谜团已经解开!如果js文件在索引中正确链接,它会有所帮助。。。。。oops

感谢那些发表评论的人!