Grunt文件没有加载ngCordova和jquery

时间:2016-05-09 13:17:28

标签: jquery angularjs gruntjs ngcordova

我有以下咕噜声的任务:



"Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
                                                                  Error: [$injector:modulerr] Failed to instantiate module ngCordova due to:
                                                                  Error: [$injector:nomod] Module 'ngCordova' is not available! You either misspelled the module name or for




我的index.html:

...



(function () {
    'use strict';

    angular
        .module('app', ['ngRoute', 'ngCookies','ngCordova'])
        .config(config);
        

    config.$inject = ['$routeProvider', '$locationProvider', '$httpProvider'];
    function config($routeProvider, $locationProvider, $httpProvider) {
        $routeProvider
            .when('/login', {
                controller: 'LoginCtrlr',
                templateUrl: 'views/login.html',
                controllerAs: 'login'
            })
            .when('/', {
                controller: 'PaymentCtrl',
                templateUrl: 'views/payment.html',
                controllerAs: 'pay'
            })
            .when('/scan', {
                controller: 'ScanCtrl',
                templateUrl: 'views/scan.html',
                controllerAs: 'scan'
            })
            .otherwise({ redirectTo: '/' });

            
            //$httpProvider.defaults.headers.post = {};
            $httpProvider.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
            //$httpProvider.defaults.headers.common['Access-Control-Allow-Origin'] = '*';



            $httpProvider.defaults.headers.post['Accept'] = 'application/json';
            $httpProvider.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8';
            $httpProvider.defaults.headers.post['Access-Control-Max-Age'] = '1728000';
            
    }

})();




但是,它没有cdnifying或复制ngCordova,我收到以下错误:



(function () {
  'use strict';
ntroller of the tickrAngularCordovaApp
   */
  angular.module('app', ['ngCordova'])
    .controller('PaymentCtrl',['$scope', 'PayService', 'cordova','$cordovaInAppBrowser',
    function ($scope, PayService,$window,cordova,$cordovaInAppBrowser){
  
      cordova.ready.then(function () {
        console.log('Cordova is ready');
        console.log("Ready....");

        var options = {
          location: 'yes',
          clearcache: 'yes',
          toolbar: 'no'
        };

        $scope.redirectPayment = function () {
          PayService.redirectPayment()
            .then(function (response) {
              
              $scope.result = response.data;
              console.log("Success!..." +  response.data);

              var urlToGo = $scope.result.data.payment_url;
              console.log("URL to redirect.." + urlToGo)
              //window.location.href = urlToGo;

              $cordovaInAppBrowser.open(urlToGo, '_self', options)
              .then(function(event) {
                // success
                console.log("Success...");
              })
              .catch(function(event) {
                // error
                console.log("Error...");
              });


              $cordovaInAppBrowser.close();

            }, 

            function (error) {
              $scope.status = 'Unable to Redirect to payment_url ' + error;
            });
        };
      });
  }]); 
  
})();




app.js并支付ctrlr:



string script = "alert(\"Your Message.\");";

            ScriptManager.RegisterStartupScript(this, GetType(),
                "ServerControlScript", script, true);






dict1 = {'a':1, 'b':2}
dict2 = {'c':3, 'd':4}
dict3 = dict1.append(dict2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'append'
dict1['dict2'] = dict2
dict1
{'a': 1, 'b': 2, 'dict2': {'c': 3, 'd': 4}}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

更改src路径并测试:

<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>

确保使用bower install ngCordova NOT! bower install ng-cordova