Farzad Karimi
Farzad Karimi

Reputation: 780

using $uibmodal to open from another controller and template

I'm somehow newbie to $uibmodal and I want to show a form in popup style for each button that I have on my page, and I want to separate code of each popup form to their own js controller and template, not inside my main js controller and template.

here's my simpled code to show the form as a popup :

 var modalInstance = $uibModal.open({
                    templateUrl: '/App/views/security/people/roleView.html',
                    controllerUrl: '/App/views/security/people/roleController.js',
                    controller: 'roleController',
                    size: 'lg',
                    resolve: {},
                });

and here is my simpled code of my controller :

define(['app'], function (app) {
    app.register.controller("roleController", ["$scope", "dataService", "$uibModal", "messageService",

    function ($scope, dataService, $uibModal, messageService) {

    debugger
}
]);
});

my problem is that whenever I click the button it give's me the error that my controller named as 'rolecontroller' is not registered.

The controller with the name 'roleController' is not registered.

thanks in advance.

Upvotes: 0

Views: 1027

Answers (1)

Marcus Höglund
Marcus Höglund

Reputation: 16801

You should add the controller in the initial bootstrap in your app.js like this

app.controller("roleController", ["$scope", "dataService", "$uibModal", "messageService",

    function ($scope, dataService, $uibModal, messageService) {

    debugger
}]);

Upvotes: 1

Related Questions