Javascript Can';由于类型错误,无法使用ngDialog:ngDialog.open不是作用域中的函数。$Scope.discountModalOpen?
我似乎无法将ngDialog与angular一起使用。这是我的密码 折扣模态函数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')
$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也被注入。谢谢您的麦克风。帮帮我!