I created a AngularJS component in ES6 like following:
import template from 'template.html'
class ctrler {
constructor ($scope, $cordovaDevice) {
$scope.title = 'This is from component'
this.$scope = $scope
document.addEventListener('deviceready', this.onDeviceReady)
}
onDeviceReady() {
console.log(this.$scope)
}
$onDestroy () {
document.removeEventListener('deviceready', this.onDeviceReady)
console.log('ctrler onDestroy');
}
}
const cpnt = {
template: template,
controller: ctrler
}
export { cpnt }
My question is what the $scope
and the $cordovaDevice
are local parameter in constructor(){}
, but I want they become global parameter, so I use this.$scope = scope
, it's not working.
How do I do?