angularjs - 我的控制台中的 Angularjs $injector:unpr 错误
问题描述
我收到 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();
}
})();
应用程序.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>
我是否缺少任何解决此错误的方法
解决方案
推荐阅读
- powershell - 将 Excel 转换为 csv UTF-8 脚本问题
- python - 从列表列表中,我如何找到具有 n 个共同元素的列表
- vue.js - 如何删除 v-expansion-panels 中的图标(vuetify)
- c# - 使用 Entity Framework Core 为 ExecuteSqlCommand() 在 SQL 中声明变量
- c# - 通过起点、终点和高度计算 3D 轨迹
- javascript - 回调函数ajax,JS
- java - Spring Boot App - Web 服务器无法启动。端口 8092 已被使用
- typescript - “GlobalEventHandlers”类型上不存在属性“classList”。在打字稿中
- reactjs - 点击后世博按钮不做任何事情
- css - 我对 react-nice-ticker 包的 css 进行了一些更改,但是当我部署代码时,我的所有更改都会覆盖