我收到angularjs $ injector.unpr错误。我试图检查拼写,但都正确。
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="">"
header.html上的标题搜索框
<form ng-submit="search()">
<input type="text" class="form-control" placeholder="Search term" ng-model="query" style="width:20%">
<button type="submit" class="btn btn-default">Search</button>
</form>
headercontroller.js
(function () {
'use strict';
var app = angular.module('myApp');
app.controller("headerController", headerController);
headerController.$inject = ['$scope', '$http', '$rootScope', '$routeParams', '$location', '$q'];
function headerController($scope, $http, $rootScope, $routeParams, $location, $q) {
var vm = this;
$scope.search = function () {
$location.path('searchIndex').search({ query: $scope.query });
};
}
})();
searchResultsController.js
(function () {
'use strict';
var app = angular.module('myApp');
app.controller("searchResultsController", searchResultsController);
searchResultsController.$inject = ['$scope', '$http', '$rootScope', '$routeParams', '$location', '$q'];
function searchResultsController($scope, $http, $rootScope, $routeParams, $location, $q) {
var vm = this;
$scope.query = $routeParams.query;
$scope.url = $location.absUrl();
}
})();
app.js
.state('searchIndex', {
url: "/searchIndex",
templateUrl: "SOC/Views/Search/index.html",
controller: "searchResultsController"
})
搜索结果index.html
<h2>Search results</h2>
<p>Query: {{query}}</p>
<p>URL: {{url}}</p>
<br>
<p>Use <code>$scope.query</code> to make a search request and display results.</p>
我缺少任何可修复此错误的信息