2015-07-12 73 views
2

我已經加入ngDialog我angularjs的應用程序,並在其注入到我的模塊,這是我得到了什麼:AngularJS ngDialog錯誤

Uncaught Error: Mismatched anonymous define() module: function (a){"use strict";var b=a.module("ngDialog",[]),c=a.element,d=a.isDefined,e=(document.body||document.documentElement).style,f=d(e.animation)||d(e.WebkitAnimation)||d(e.MozAnimation)||d(e.MsAnimation)||d(e.OAnimation),g="animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",h="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",i=!1,j={},k=[],l=!1;return b.provider("ngDialog",function(){var b=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,closeByNavigation:!1,appendTo:!1,preCloseCallback:!1,overlay:!0,cache:!0,trapFocus:!0,preserveFocus:!0,ariaAuto:!0,ariaRole:null,ariaLabelledById:null,ariaLabelledBySelec

什麼是這個錯誤的原因是什麼?我必須修改ngDialog.js代碼嗎?

新增信息: 注入在module.js:

var app = angular.module('myApp', ['...', ...., 'ngDialog']); 

***,當我在我的控制器注入ngdialog這樣的:

app.controller('myController', ['$scope','$http','ngDialog', function ($scope,$http,ngDialog) { ... 

這是錯誤我得到:

Error: [$injector:unpr] Unknown provider: ngDialogProvider <- ngDialog <- inventoryController 

回答

0

我猜你正在使用RequireJS?

從他們common errors page

  • Be sure to load all scripts that call define() via the RequireJS API. Do not manually code script tags in HTML to load scripts that have define() calls in them.
  • If you manually code an HTML script tag, be sure it only includes named modules, and that an anonymous module that will have the same name as one of the modules in that file is not loaded.
  • If the problem is the use of loader plugins or anonymous modules but the RequireJS optimizer is not used for file bundling, use the RequireJS optimizer.
  • If the problem is the var define lint approach, use /*global define */ (no space before "global") comment style instead.

如果你發佈你是如何引用ngDialog的一些代碼,那麼也許我可以幫助更多。

+0

好吧你是對的我正在使用RequireJS,並有一些硬編碼嘗試,因爲我失去了希望..我刪除他們現在沒有錯誤,但仍ngDialog沒有定義@Buh Buh – sisimh

+0

好吧,好。發佈您創建模塊的地方的代碼。還有使用ngDialog的控制器的代碼。 –

+0

好吧等一下我想添加一些東西@Buh Buh,這就是我的所作所爲:我有一個庫,我正在添加到我的應用程序的列表..我循環他們所有然後縮小它們成一個大文件..所以結果是一個所有庫的文件好嗎? 之後,我將這個大js文件包含在索引中,如