gpt4 book ai didi

javascript - 如何在 AngularJS Controller 中使用依赖关系

转载 作者:行者123 更新时间:2023-11-28 07:02:51 26 4
gpt4 key购买 nike

我正在制作 MEANJS 应用程序。我有一个 AngularJS Controller ,我想在其中使用 Snoocore。

https://snoocore.readme.io/

'use strict';


angular.module('core').controller('HomeController', ['$scope', 'Authentication', 'snoocore',function($scope, Authentication, Snoocore) {
// This provides Authentication context.
$scope.authentication = Authentication;

var reddit = new Snoocore({
userAgent: 'test@documentation',
oauth: {
type: 'implicit', // required when using implicit OAuth
mobile: true, // defaults to false.
key: '', // Only requires the key! No secret needed.
redirectUri: 'redirectUri set for your app',
scope: [ 'read', 'flair', 'identity' ] // make sure to set all the scopes you need.
}
});
}
]);

我已经通过 Bower 导入了 Snoocore。它位于

public/lib/snoocore

Controller 位于

public/modules/core/controllers/home.client.controller.js

现在我正在做的事情不起作用。我有点不知所措。总的来说,我对 Angular 和 MEANJS 系统还很陌生。

控制台输出以下内容

Error: [$injector:unpr] Unknown provider: snoocoreProvider <- snoocore
http://errors.angularjs.org/1.2.28/$injector/unpr?p0=snoocoreProvider%20%3C-<section data-ui-view="" class="ng-scope">noocore
at http://localhost:3000/lib/angular/angular.js:78:12
at http://localhost:3000/lib/angular/angular.js:3801:19
at Object.getService [as get] (http://localhost:3000/lib/angular/angular.js:3929:39)
at http://localhost:3000/lib/angular/angular.js:3806:45
at getService (http://localhost:3000/lib/angular/angular.js:3929:39)
at invoke (http://localhost:3000/lib/angular/angular.js:3956:13)
at Object.instantiate (http://localhost:3000/lib/angular/angular.js:3976:23)
at http://localhost:3000/lib/angular/angular.js:7315:28
at chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1544:22
at http://localhost:3000/lib/angular/angular.js:6711:34

最佳答案

我添加了标签

<script src="/lib/snoocore/dist/Snoocore-browser.min.js"></script>

到我的 HTML 头并将我的 Controller 更改为如下所示。

'use strict';


angular.module('core').controller('HomeController', ['$scope', 'Authentication' ,function($scope, Authentication) {
// This provides Authentication context.
$scope.authentication = Authentication;

var reddit = new Snoocore({
userAgent: 'test@documentation',
oauth: {
type: 'implicit', // required when using implicit OAuth
mobile: true, // defaults to false.
key: '', // Only requires the key! No secret needed.
redirectUri: 'redirectUri set for your app',
scope: [ 'read', 'flair', 'identity' ] // make sure to set all the scopes you need.
}
});

}
]);

关于javascript - 如何在 AngularJS Controller 中使用依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31958951/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com