0

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?

1 Answer 1

1

Put your variable declaration into the constructor

class DemandCtrl {

    constructor(ChartDataService) {
        this.ChartDataService = ChartDataService;
        this.dataa = {
            from: '',
            to: ''
        };
    }

    $onInit() {
        getData.call(null, this);       
    }

}
Sign up to request clarification or add additional context in comments.

1 Comment

might wanna declare the variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.