我在header.html页的标题中有一个全局搜索框
header.html
<div class="col-md-4" style="float:right; margin-right:0px;">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" id="txtSearch" />
<div class="input-group-btn">
<button class="btn btn-primary" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</div>我有headerController.js
function headerController($scope, $http, $rootScope) {
var vm = this;
}Index1.html
这是索引1页。索引1太美了
Index2.html
这是索引2页。索引2太棒了
索引3.html
这是索引3页。索引3太可爱了
我是使用angularjs开发的,所以当我搜索beautiful关键字时,它应该会显示一个弹出窗口(不是警告),美丽的单词在索引1页中。如果我搜索单词wonderful,它应该会在弹出窗口(而不是警告)中显示精彩在索引2页中。我尝试过其他静态搜索类型,它们指向要过滤和搜索的元素的ng重复列表。但是我怎样才能做到这一点呢?
我试图查看此示例,但我得到了一个错误
http://plnkr.co/edit/FMRTTbxdNv0pGSYpfwve?p=preview
错误是
Error: [$injector:unpr] http://errors.angularjs.org/1.7.2/$injector/unpr?p0=%24routeParamsProvider%20%3C-%20%24routeParams%20%3C-%20searchResultsController
at angular.js:99
at angular.js:4891
at Object.d [as get] (angular.js:5051)
at angular.js:4896
at d (angular.js:5051)
at e (angular.js:5076)
at Object.instantiate (angular.js:5120)
at angular.js:11175
at Object.<anonymous> (angular-ui-router.min.js:7)
at angular.js:1364 "<div class="well ng-scope" ui-view="">"发布于 2018-11-30 05:39:46
在您的SearchResultsController中类似于以下内容(未经测试):
$scope.results = [];
$http.get(url1).then(function(result){if(result.data.contains($scope.query)) $scope.results.push("url1")});
$http.get(url2).then(function(result){if(result.data.contains($scope.query)) $scope.results.push("url2")});
$http.get(url3).then(function(result){if(result.data.contains($scope.query)) $scope.results.push("url3")});然后在您的html页面中:
<div ng-repeat="result in results">Found in: {{result}}</div>https://stackoverflow.com/questions/53546207
复制相似问题