AngularJS错误:在声明我的控制器时获取:areq Bad Argument

时间:2016-07-28 19:01:59

标签: javascript angularjs

我是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>

1 个答案:

答案 0 :(得分:0)

这个谜团已经解决了! 如果js文件在索引中正确链接会有帮助..... oops

感谢那些评论的人!