简体   繁体   English

将模块注入角度作为未找到的模块

[英]Injecting a module into angular as module not found

I can't seem to inject a module into my angular app. 我似乎无法在我的角度应用程序中注入一个模块。

I am trying to import the following module which is installed through bower using: 我正在尝试导入以下通过bower安装的模块:

bower install angular-pagedown --save

This seems to load fine within the bower-components folder which is in the following folder structure: 这似乎在bower-components文件夹中正常加载,该文件夹位于以下文件夹结构中:

clinet
------app
---------bower-components
-------------------angular-pagedown
-------------------pagedown

When I try inject the module as it says in the instructions using 'ui.pagedown' which is indeed the name of the module, I use the following code in app.js: 当我尝试使用'ui.pagedown'(在模板中确实是模块名称)的说明中注入模块时,我在app.js中使用以下代码:

import _Auth from '../components/auth/auth.module';
import account from './account';
import admin from './admin';
import navbar from '../components/navbar/navbar.component';
import footer from '../components/footer/footer.component';
import main from './main/main.component';
import questionsCreate from 
'./questionsCreate/questionsCreate.component';
import questionsShow from './questionsShow/questionsShow.component';
import constants from './app.constants';
import util from '../components/util/util.module';
import socket from '../components/socket/socket.service';


import './app.scss';

angular.module('filQuestionsApp', [ngCookies, ngResource, ngSanitize, 
'btford.socket-io', uiRouter,
  uiBootstrap, _Auth, account, admin, 'validation.match', navbar, 
footer, main, questionsCreate,
  questionsShow, constants, socket, util, 'ui.pagedown'
])

I seem to get the following error when trying to use the module: 尝试使用该模块时,我似乎遇到以下错误:

Module 'ui.pagedown' is not available! 模块'ui.pagedown'不可用! You either misspelled the module name or forgot to load it. 您要么错误拼写了模块名称,要么忘记加载它。 If registering a module ensure that you specify the dependencies as the second argument. 如果注册模块,请确保将依赖项指定为第二个参数。

I seem to be doing something really wrong with bower and angular together, I'm also getting 400 errors in terms of formatting and I'm not sure on the injection process. 我似乎正在做一些真正错误的凉亭和角度,我在格式方面也遇到了400 errors ,我不确定注射过程。

How angular-pagedown work: angular-pagedown如何工作:

bower install angular-pagedown --save

This will also install pagedown dependencies. 这也将安装pagedown依赖项。 Import these files in your HTML: 在HTML中导入这些文件:

pagedown/Markdown.Converter.js
pagedown/Markdown.Sanitizer.js
pagedown/Markdown.Extra.js
pagedown/Markdown.Editor.js
angular-pagedown/angular-pagedown.js
angular-pagedown/angular-pagedown.css

If you're using a build tool like grunt/gulp's main-bower-files, you don't need to import the files manually. 如果您使用的是像grunt / gulp的main-bower文件这样的构建工具,则无需手动导入文件。 But add this in your bower.json 但是在你的bower.json添加它

"overrides": {
  "pagedown": {
    "main": [
      "Markdown.Converter.js",
      "Markdown.Sanitizer.js",
      "Markdown.Extra.js",
      "Markdown.Editor.js",
      "wmd-buttons.png"
    ]
  }
}

Include dependency in your app angular.module("yourApp", ["ui.pagedown"]); 在您的应用中包含依赖项angular.module("yourApp", ["ui.pagedown"]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM