Im having some trouble with $mdDialog function for AngularJS material. The prosess is like this:
1) HTTP.get request to API and save the data into $scope
2) ng-repeat on view for table
3) User can click on a row and modal is shown (this is problem)
4) The data from row clicked will be shown in modal as title
As you can see my AngularJS controller code:
$scope.showAdvanced = function(ev, variable_name) {
console.log(variable_name);
$mdDialog.show({
locals:{dataToPass: variable_name},
templateUrl: 'save-dialog.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
isolateScope: false,
controller: DialogController
})
.then(function(answer) {
$scope.status = 'You said the information was "' + answer + '".';
}, function() {
$scope.status = 'You cancelled the dialog.';
});
function DialogController($scope, $mdDialog) {
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};
}
};
The error message i get in console is this(This happends ONLY when i add the line controller: DialogController
inside $mdDialog.show
, and im following the documentation right:
variable_name
is just a variable that i get from the row clicked, if anyone have any better solution please tell. Purpose of the modal is to write some data inside modal and click submit that sends data to DB.
This is the error message:
main.min.js:3 Error: [$injector:unpr] Unknown provider: tProvider <- t
http://errors.angularjs.org/1.5.11/$injector/unpr?p0=tProvider%20%3C-%20t
at main.min.js:2
at main.min.js:2
at Object.r [as get] (main.min.js:2)
at main.min.js:2
at r (main.min.js:2)
at i (main.min.js:2)
at Object.a [as invoke] (main.min.js:2)
at c.instance (main.min.js:3)
at o._createController (main.min.js:17)
at Object.i [as link] (main.min.js:17)
Using anonymous controller should solve your issue.
Concerning your
dataToPass
, you need to inject it too.