简体   繁体   English

mean.js应用程序中的ngDialog

[英]ngDialog in mean.js application

I have created a webapp with MeanJS. 我用MeanJS创建了一个webapp。 I want to use ngDialog in the application, but not sure how and where to add the ngDialog.js in the application. 我想在应用程序中使用ngDialog,但不确定在应用程序中添加ngDialog.js的方式和位置。 Im trying to inject the ngDialog in the controller as shown below, but everytime error as unknown provider 我试图在控制器中注入ngDialog,如下所示,但每次都是错误的未知提供者

angular.module('myModule').controller('MyController', ['$scope', '$http', 'ngDialog', function ($scope, $http, ngDialog) { angular.module('myModule')。controller('MyController',['$ scope','$ http','ngDialog',function($ scope,$ http,ngDialog){

error : Error: [$injector:unpr] Unknown provider: ngDialogProvider <- ngDialog 错误:错误:[$ injector:unpr]未知提供者:ngDialogProvider < - ngDialog

Can anyone please let me know how to include the ngDialog in the meanjs application. 任何人都可以让我知道如何在meanjs应用程序中包含ngDialog。

Thanks in advance 提前致谢

You should use bower to install ngDialog first. 您应该首先使用bower来安装ngDialog In your application root (where bower.json is located), issue the following command, 在您的应用程序根目录(bower.json所在的位置)中,发出以下命令:

bower install --save ngDialog

Then, make sure you add ngDialog module in the app level. 然后,确保在应用程序级别添加ngDialog模块。 The following answer is specific to MEAN.JS. 以下答案特定于MEAN.JS.

In file public/config.js , find the line 在文件public/config.js ,找到该行

var applicationModuleVendorDependencies = ['ngResource', 'ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils'];

Add 'ngDialog' to the end of the list 'ngDialog'添加到列表的末尾

var applicationModuleVendorDependencies = ['ngResource', 'ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngDialog'];

Then, include ngDialog's CSS and JavaScript file into the HTML template of the Angular application. 然后,将ngDialog的CSS和JavaScript文件包含在Angular应用程序的HTML模板中。

In file config/env/all.js , find assets.lib.css , append 'public/lib/ngDialog/css/ngDialog.min.css' to the list. 在文件config/env/all.js ,找到assets.lib.css ,将'public/lib/ngDialog/css/ngDialog.min.css'到列表中。

In the same file, find assets.lib.js , append 'public/lib/ngDialog/js/ngDialog.min.js' to the list. 在同一个文件中,找到assets.lib.js ,将'public/lib/ngDialog/js/ngDialog.min.js'到列表中。

您应该在模块中添加ngDialog模块,如下所示: angular.module('myModule', ['ngDialog']).controller('MyController' ...

The original answer is still correct but for the new Mean.js 0.4 some stuff changed. 原来的答案仍然是正确的,但对于新的Mean.js 0.4,一些东西改变了。

You still use 你仍然使用

bower install --save ngDialog

to install ngDialog. 安装ngDialog。

To add the dependency 'ngDialog' go to modules/core/client/app/config.js and add 要添加依赖项'ngDialog'请转到modules/core/client/app/config.js并添加

var applicationModuleVendorDependencies = ['ngResource', 'ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngDialog'];

Then this is where I struggled. 然后这就是我挣扎的地方。

To include ngDialog's CSS and JavaScript file into the HTML template of the Angular application go to 要将ngDialog的CSS和JavaScript文件包含到Angular应用程序的HTML模板中,请转到

config/assets/default.js

and under client.lib.css add 'public/lib/ng-dialog/css/ngDialog.min.css' client.lib.css下添加'public/lib/ng-dialog/css/ngDialog.min.css'

and client.lib.js add 'public/lib/ng-dialog/js/ngDialog.min.js' . client.lib.js添加'public/lib/ng-dialog/js/ngDialog.min.js'

Note that the path of ngDialog changed to ng-dialog. 请注意,ngDialog的路径已更改为ng-dialog。

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

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