控制台错误提示
ionic.bundle.js:26794 Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- DutylogService http://errors.angularjs.org/1.5.3/$injector/unpr?p0=<ion-nav-view name="tab-dutylog" class="view-container tab-content" nav-view="active" nav-view-transition="ios">copeProvider%20%3C-%20%24scope%20%3C-%20DutylogService at http://localhost:8100/lib/ionic/js/ionic.bundle.js:13438:12 at http://localhost:8100/lib/ionic/js/ionic.bundle.js:17788:19 at .getService [as get] (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17941:39) at http://localhost:8100/lib/ionic/js/ionic.bundle.js:17793:45 at getService (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17941:39) at injectionArgs (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17965:58) at .instantiate (http://localhost:8100/lib/ionic/js/ionic.bundle.js:18007:18) at .<anonymous> (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17850:24) at .invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17995:19) at .enforcedReturnValue [as $get] (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17834:37)
原因:
angular.module('myModule', [])
.service('MyController', ['$scope', function($scope) {
// This controller throws an unknown provider error because
// a scope cannot be injected into a service.
}]);
建议方式:
.service('DutylogService', [function(){
}])
以上这篇解决angularjs service中依赖注入$scope报错的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
Wifi上线!威海市图书馆无线网免费开放
2026-05-18栏目: 教程
-
企业如何选择网络安全防护公司?
2026-05-18栏目: 教程
-
调查显示:中国88%员工信任机器人超过经理
2026-05-18栏目: 教程
-
月神脚本圈:互联网时代日新月异,引流脚本助你抓住商机
2026-05-18栏目: 教程
-
做外贸客户的货物被海关扣押了怎么办?
2026-05-18栏目: 教程
