angularjs无法加载jaydata模块

时间:2015-03-30 12:53:03

标签: javascript angularjs jaydata

创建AngularJS应用。我必须使用Jaydata来使用odata3网络服务。我正在使用名为Metronics的主题。

我在控制台中看到的错误是:

http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=MetronicApp&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.3.15%2F%24injector%2Fmodulerr%3Fp0%3Doc.lazyLoad%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.3.15%252F%2524injector%252Fnomod%253Fp0%253D%252524provide%250A%2520%2520%2520%2520at%2520Error%2520(native)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A6%253A417%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A21%253A412%250A%2520%2520%2520%2520at%2520a%2520(http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A21%253A53)%250A%2520%2520%2520%2520at%2520Object.w.bootstrap%2520%255Bas%2520module%255D%2520(http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A21%253A296)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%253A31176%252Fassets%252Fglobal%252Fplugins%252Fangularjs%252Fplugins%252FocLazyLoad.min.js%253A8%253A2925)%250A%2520%2520%2520%2520at%2520Object.r%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A7%253A302)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%253A31176%252Fassets%252Fglobal%252Fplugins%252Fangularjs%252Fplugins%252FocLazyLoad.min.js%253A8%253A2994)%250A%2520%2520%2520%2520at%2520Object.r%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%253A31176%252FScripts%252Fangular.min.js%253A7%253A302)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%253A31176%252Fassets%252Fglobal%252Fplugins%252Fangularjs%252Fplugins%252FocLazyLoad.min.js%253A8%253A2994)%0A%20%20%20%20at%20Error%20(native)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A6%3A417%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A35%3A320%0A%20%20%20%20at%20r%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A7%3A302)%0A%20%20%20%20at%20g%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A34%3A399)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A35%3A63%0A%20%20%20%20at%20r%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A7%3A302)%0A%20%20%20%20at%20g%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A34%3A399)%0A%20%20%20%20at%20ab%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A38%3A135)%0A%20%20%20%20at%20d%20(http%3A%2F%2Flocalhost%3A31176%2FScripts%2Fangular.min.js%3A17%3A381

我在app.js中添加了所需的模块(即' jaydata')



'use strict';

var app = angular.module("app", [  
    "ui.router", 
    "ui.bootstrap", 
    "oc.lazyLoad",  
    "ngSanitize",
    "jaydata"  // <=== when I remove this and remove $data from controller, everything except jaydata specific things work.
]); 

/* Setup Rounting For All Pages */
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    // Redirect any unmatched url
    $urlRouterProvider.otherwise("/Dashboard");
  
  //... states of all pages/routes using $stateProvider 
  
  ]);
  
  
// this controller is in separate file. loaded by lazyLoad along with the view
  // when I remove $data from this controller and 'jaydata' from app, everything except jaydata specific things work.
app.controller('TicketsController',[ '$rootScope','$data', '$scope', '$http', '$timeout',function ($rootScope,$data, $scope, $http, $timeout) {
    $scope.$on('$viewContentLoaded', function () {
        theme.initAjax(); // initialize core components        
    });
    console.log($data);
  
  //jaydata specific code.
  
  // set sidebar closed and body solid layout mode
    $rootScope.settings.layout.pageBodySolid = false;
    $rootScope.settings.layout.pageSidebarClosed = false;
}]);
&#13;
<!-- the view loads here-->
<div ui-view class="fade-in-up">
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://include.jaydata.org/jaydata.js"></script>
<script src="http://include.jaydata.org/datajs-1.0.3.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="http://include.jaydata.org/jaydatamodules/angular.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-sanitize.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-touch.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"></script>
<script src="http://raw.githubusercontent.com/ocombe/ocLazyLoad/master/dist/ocLazyLoad.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js"></script>
&#13;
&#13;
&#13;

请帮忙。 你会在这里找到主题的代码: http://www.keenthemes.com/preview/metronic/theme/templates/admin/angularjs/#/dashboard.html

2 个答案:

答案 0 :(得分:1)

'oc.lazyLoad'模块是与jaydata冲突的模块。

当我遇到这个问题时,我删除了该模块,然后jaydata工作了。

答案 1 :(得分:0)

您似乎应该从app

MetronicApp MetronicApp将您的变量名称替换为app

<强>代码

var app= angular.module("app", [  
    "ui.router", 
    "ui.bootstrap", 
    "oc.lazyLoad",  
    "ngSanitize",
    "jaydata"  // <=== when I remove this and remove $data from controller, everything except jaydata specific things work.
]);