使用AngularJS搜索提交时出现引用错误
我在使用angularJS提交时遇到搜索问题 这是html,包含insied模块和控制器使用AngularJS搜索提交时出现引用错误,angularjs,angularjs-scope,referenceerror,Angularjs,Angularjs Scope,Referenceerror,我在使用angularJS提交时遇到搜索问题 这是html,包含insied模块和控制器 <form ng-submit="search()"> <div class="input-group col-md-6 typeahead-wrapper"> <input type="text" ng-model="searchkeyword.keystring" id="searchField" placeholde
<form ng-submit="search()">
<div class="input-group col-md-6 typeahead-wrapper">
<input type="text" ng-model="searchkeyword.keystring" id="searchField" placeholder="Type any keyword to search for a Masjid" class="form-control typeahead">
<span class="input-group-btn">
<button class="btn btn-primary" id="goSearch" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div><!-- /input-group -->
</form>
当我提交时,它给出了错误
ReferenceError:未定义searchkeyword
谢谢您的帮助。尝试使用
$scope.searchkeyword
您只使用了searchkeyword
var url = 'http://localhost/json/search.php?params='+$scope.searchkeyword;
$http.get(url).function(response) { .....
更改以下代码
$http.get('http://localhost/json/search.php', { params: searchkeyword },
到
$scope.searchkeyword应位于http.getHanks中,已删除该错误,但不进入响应/失败函数。$http.get(')……您不应将回调传递给http.get,它会返回一个promis,因此您必须使用http.get()。然后(successcalback,errorcalback)错误:未定义响应。按照相同的方式完成,但使用@MiTa建议的回调,谢谢
$http.get('http://localhost/json/search.php', { params: searchkeyword },
$http.get('http://localhost/json/search.php', { params: $scope.searchkeyword },