Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';由于类型错误,无法使用ngDialog:ngDialog.open不是作用域中的函数。$Scope.discountModalOpen?_Javascript_Angularjs_Ng Dialog - Fatal编程技术网

Javascript Can';由于类型错误,无法使用ngDialog:ngDialog.open不是作用域中的函数。$Scope.discountModalOpen?

Javascript Can';由于类型错误,无法使用ngDialog:ngDialog.open不是作用域中的函数。$Scope.discountModalOpen?,javascript,angularjs,ng-dialog,Javascript,Angularjs,Ng Dialog,我似乎无法将ngDialog与angular一起使用。这是我的密码 折扣模态函数 $scope.discountModalOpen = function () { ngDialog.open({ template: 'views/discountModal.html', controller: 'ModalInstanceCtrl', scope: $scope }); }; 折扣模式控制器 angular.module('myApp')

我似乎无法将ngDialog与angular一起使用。这是我的密码

折扣模态函数

 $scope.discountModalOpen = function () {
  ngDialog.open({
      template: 'views/discountModal.html',
      controller: 'ModalInstanceCtrl',
      scope: $scope
    });
  };
折扣模式控制器

angular.module('myApp')
.controller('myProductsCtrl', 
['$scope', '$stateParams', 'productService', '$modal','ngDialog', '$filter','$location',
function ($scope, $stateParams, productService, $modal, $filter,ngDialog, $location) {
 });
app.js

angular
.module('myApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngSanitize',
'ngTouch',
'restangular',
'ui.router',
'ui.bootstrap',
'angularMoment',
'timer',
'ngMessages',
'ngDialog'
])
我的javascript控制台中仍然出现以下错误

TypeError:ngDialog.open不是函数 范围为$Scope.discountModalOpen() 在fn处(评估时间(),:4:242) 在 范围为$get.Scope.$eval() 范围为$get.Scope.$apply() 在HTMLButtoneElement。() 在HTMLButtonElement.jQuery.event.dispatch()处
在HTMLButtonElement.jQuery.event.add.elemData.handle()

中,我想冒昧地说,问题在于您的可注入项顺序错误:

angular.module('myApp')
.controller('myProductsCtrl', 
['$scope', '$stateParams', 'productService', '$modal','ngDialog', '$filter','$location',
function ($scope, $stateParams, productService, $modal, ngDialog, $filter, $location) {
 });

您的
ngDialog
被注入
$filter
中,而visa也被注入。

谢谢您的麦克风。帮帮我!