Looking at other threads on stack overflow, it looks complicated to have private methods/variables within an ES6 Class.
I'm using Angular 1.5 but Controllers in Angular 2 are written using Classes. We wanted to make our code ready for a future migration.
This cause a problem: all the methods and variables within that Class are now available in the view, so you can from the view (the HTML), invoke MyController.privateMethod();
which is an issue.
How do we deal with that? I would prefer to use an ES6 module but I'm not sure it's recommended for an Angular 2 Controllers migration.
Here is a code example:
class MyController {
constructor(){
this.foo = 'foo';
}
privateMethod() {
...
}
publicMethod(){
...
}
}
angular.module('myApp').controller('MyController', MyController);
Thanks!