0

I'm trying to include a angularui modular dialog in my app

In my controller.js

define([ 'app' ], function(app) {
  app.controller('TeacherClasses',
  [ '$scope', '$http', '$dialog','$location', 'anotherservice',
  function($scope, $http, $location, $dialog, anotherservice) {
$scope.opts = {
        backdrop: true,
        keyboard: true,
        backdropClick: true,
        template:  '/pathto/partial.html'
    };

    $scope.openDialog = function(studentGroup){
        $scope.newClass = angular.copy(studentGroup);
        var modal = $dialog.dialog($scope.opts);
        modal.open();
    }
    }]);

return app;
});

I've added the ui.bootstrap.dialog to the angular module in app.js

var myModule = angular.module('myApp', 
[ 'ngResource', 'ui', 'infinite-scroll', 'ngDragDrop', 'blueimp.fileupload','ui.bootstrap.dialog', 'ui.bootstrap.modal',
  'ui.bootstrap.dropdownToggle', 'LoadingIndicator', 'http-auth-interceptor']);

Now, I keep hitting an TypeError: Object # has no method 'dialog' at Object.$scope.openDialog error.

What am I doing wrong?

4

1 回答 1

3

The order in which you list your dependencies is the order that they will be passed to your controller function. Since $dialog is the third entry in your dependencies array, it should be the third argument in your function.

于 2013-08-28T13:44:40.767 回答