I have the following code :
(function () {
'use strict';
angular.module('gestion').controller(
'controller',
controller);
controller.$inject = ['$mdDialog',
'locals'];
function controller($mdDialog, locals) {
var pm = this;
pm.cancel = function () {
$mdDialog.hide();
};
pm.validate = function () {
$mdDialog.hide();
locals.parentScope.remove();
};
}
})();
The problem is that when I run jshint
I get this warning message:
If a strict mode function is executed using function invocation, its 'this' value will be undefined.
How can I solve this ?
Edit:
I don't know why this question has been marked as duplicated.
Edit 2:
I solved the problem when I used Controller
instead of controller
, this has to deal with the Constructor Invocation Pattern
, since you should capitalise the first character of the name of a function when you need to construct the object by "new" keyword, which var pm = this
does in this case.