我是Angular的新手,我无法找到我正在尝试使用的控制器出现的“Bad Argument”错误的解决方案。 我不确定它是否完全是其他东西,或者我是如何定义控制器本身的。
提前感谢您的任何反馈!
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);
});
};
}]);
<div id="qASectionContain" ng-controller="questionCtrl">
<input id="qASectionHead" placeholder="ask this business a question">
<button ng-click="askButton()">
ask
</button>