2017-10-23 9 views
0

変数に保存された2つのテキスト入力で書き込まれたデータを取得したいと考えています。AngularJSの変数へのテキスト入力

これは私の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> 

これは、すでに存在するコントローラです。私はそれを変更することはできませんし、それは古典的なものに比べて異なって見える。おそらくそれは、私は私のコードエディタからこのメッセージが表示されますので、そのようにそれをここに追加する正しい方法ではありません

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 
}; 

私はここに変数を追加する必要があります

[js]予期しないトークンです。コンストラクタ、メソッド、アクセサまたはプロパティ が必要です。

これを解決する方法はありますか?

答えて

1

constructor

class DemandCtrl { 

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

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

} 
+0

にあなたの変数宣言を入れて、変数を宣言したい場合があります。 –

関連する問題