“Unknown provider: ngDialogProvider”

后端 未结 2 812
盖世英雄少女心
盖世英雄少女心 2021-01-18 02:23

In my app.js I have

var app = angular.module(\"atlas\", [\"ngRoute\", \"ngDialog\"]);

for my controller I have



        
相关标签:
2条回答
  • 2021-01-18 02:33

    the problem was the config of ngDialogProvider

    after var app = angular.module("atlas", ["ngRoute", "ngDialog"]);

    we have to use:

    app.config(["ngDialogProvider", function (ngDialogProvider) {
        ngDialogProvider.setDefaults({
            className: "ngdialog-theme-default",
            plain: false,
            showClose: true,
            closeByDocument: true,
            closeByEscape: true,
            appendTo: false,
            preCloseCallback: function () {
                console.log("default pre-close callback");
            }
        });
    }]); 
    
    0 讨论(0)
  • 2021-01-18 02:49

    I experienced the same error message when I first tried to add ngDialog to my app, and I tried the ngDialogProvider fix outlined by Disposer above. It didn't work for me. Then I realised that my app was partitioned into two modules; a top level module defining the controller, and core module defining a service with some lower level code. My code is structured that way because I started with the angular-phonecat tutorial as boilerplate. I was injecting ngDialog into the controller, and attempting to use it in the service. Once I fixed the injection to be into the correct module the issue was resolved.

    0 讨论(0)
提交回复
热议问题