0

当我尝试调用 openDialog 函数表单视图时,出现以下错误 ngDialog.open is not a function here is my code

(function () {
    'use strict';
    angular
        .module('app.user')
        .controller('userController', Controller);

    Controller.$inject = ['$rootScope', '$log', 'ngDialog', 'tpl','DataService'];

    function Controller($rootScope, $log,ngDialog,tpl, DataService) {

        var vm = this;
        vm.user = {};
        vm.createUser = function() {
            DataService.createUser(user);
        }
        vm.openDialog = function() {
        $log.log('vm.openDialog is running')
        ngDialog.open({
            template: 'createUser',
            className: 'ngdialog-theme-default'
        })
        }
        activate();


        function activate() {

        }

    }
})();

那么可能是什么问题?谢谢你 。

4

2 回答 2

0

在这里查看完整的工作演示。

你忘了添加.module('app.user',['ngDialog'])

ngDialog.open(
{
    template: 'createUser',
    className: 'ngdialog-theme-default'
});

http://plnkr.co/edit/dpbE6lgQDxJYZYOXqU6j?p=preview

于 2016-04-23T08:16:08.383 回答
0

试试这个

function Controller($rootScope, $log, ngDialog ,tpl, DataService) {

        var vm = this;
        vm.user = {};
        vm.createUser = function() {
            DataService.createUser(user);
        }
        ngDialog.open = function() {
        $log.log('vm.openDialog is running')
        ngDialog.open({
            template: 'createUser',
            className: 'ngdialog-theme-default'
        })
        }
        activate();
于 2016-04-23T08:17:50.133 回答