Closed fecabianchi closed 7 years ago
w/ ES6 you have to inject deps as arguments of the constructor of the ES6 class.
if you use preprocessing tools like ng-inject you have to add the string literals "ngInject";
as first line of the constructor.
class AppCtrl {
constructor($myDependency) {
'ngInject';
this.url = 'https://github.com/preboot/angular-webpack'
this.myDependency = $myDependency
}
}
feel free to reopen if you have have problems.
Thanks for the answer but i still have problems...
i'm trying to do like that
export default class LoginController {
constructor($state) {
'ngInject';
this.state = $state
}
changeState() {
state.go('app.home')
}
}
but when i fire changeState nothing happens.
you have missed the this keyword in changeState function. (it's a ES6 class)
Hi, how can i inject $state on the controller?
Thanks in advance.