I have a controller that call my service ( a factory ) in the view.
The goal of my service is to load a $mdDialog and the user write some data
inside and then valid.
Everything work ( data binding etc ) between controller and service except
the fact that i can't .then() in my controller.
Here is the call in my controller of the service :
function callSomeone(data) {
communicationservice.callSomeone(data).then(function(e) {
// doing stuff after the validation of the $mdDialog
console.log('dadada');
});
}
Service :
function communicationservice($mdDialog, dataservice, logger) {
var service = {
callSomeone:callSomeone
};
return service;
function callSomeone(data) {
console.log('communicationservice callSomeone');
$mdDialog.show({
controller: CommunicationController,
templateUrl: 'tpl/createCommunication.tmpl.html',
parent: angular.element(document.body),
clickOutsideToClose:false,
locals : {
message : data
}
}).then(function(result) {
var input = {};
input.commentaireCommunication = result[0];
input.idClient = data.idRefClient;
input.dateCommunication = new Date().toISOString().slice(0,
19).replace('T', ' ');
dataservice.sendRequest('post','communication/', input);
});
}
function CommunicationController($scope, $mdDialog, message) {
$scope.message = message;
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};
$scope.submit = function() {
var coms = document.getElementsByName('com')[0].value;
$mdDialog.hide([coms]);
};
}
When i do that i got a message error and i don't get the
console.log('dadada');
l.callSomeone(...) is undefined
BUUUUUT my callSomeone function is called because everything is done. Soooo
how to do that ?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.