How to use different controller for model in angularjs -


i have 1 controller named controller1 has bellow code open modal dialog

var opendilaogbox = function () {   $scope.modalinstance = $modal.open({     templateurl : 'templatepth here',     controller  : controller2,     keyboard    : false,     backdrop    : false   }); } 

i want use controller2 modal dialog. please help.

just use name of controller2. example, if controller2's name modalctrl, can this:

var opendialogboxwithparams = function (param) {     var modalinstance = $modal.open({         templateurl: '../path/to/modal.html',         controller: 'modalctrl',         scope: $scope,         resolve: { param: function () { return param } }     });     modalinstance.result.then(function (returnvalue) {         $scope.somedata = returnvalue;     }, function () { }); }; 

just make sure modalctrl injected app properly, i.e.

app.controller('modalctrl', ['$scope', ... 

Comments