Reputation: 3125
I want to get the data written in two text inputs saved into variables.
This is my rtmNav.html:
<div class="rtm-nav">
<label>From:
<input type="text" name="input" ng-model="ctrl.dataa.from">
</label>
<label>To:
<input type="text" name="input" ng-model="ctrl.dataa.to">
</label>
</div>
This is the controller that already exists. I cannot change it's structure and imo it looks different compared to a classic one. I must add the variables here:
demand.js
class DemandCtrl {
constructor(ChartDataService) {
this.ChartDataService = ChartDataService;
}
$onInit() {
getData.call(null, this);
}
/////////////// THIS IS WHERE I GUESS I SHOULD ADD THE VARIABLES
this.dataa = {
from: '',
to: ''
};
////////////
}
... other methods ...
export const Demand = {
bindings: {
data: '<'
},
templateUrl: demandPageHtml,
controller: DemandCtrl
};
Probably it is not the correct way to add it here like that because I get this message from my code editor:
[js] Unexpected token. A constructor, method, accessor, or property was expected.
Any ideas how to solve this?
Upvotes: 0
Views: 34
Reputation: 68635
Put your variable declaration into the constructor
class DemandCtrl {
constructor(ChartDataService) {
this.ChartDataService = ChartDataService;
this.dataa = {
from: '',
to: ''
};
}
$onInit() {
getData.call(null, this);
}
}
Upvotes: 1