vendredi 18 août 2017

How to take input from template and store it in javascript variable in Ember?

I tried like this

app/template/print-dept.hbs

<form action="/print-dept-wise">
Department: <input type="text" id="dept"><br/><br/>
<input type="submit" value="Submit">
</form>

app/template/print-dept-wise.hbs


Employee Id:  <br/>
First Name:  <br/>
Last Name:  <br/>
Employee Dept:  <br/>
<br/>


app/route/print-dept-wise.js

import Ember from 'ember';

export default Ember.Route.extend({
model() {
var text = document.getParameterById("dept");
return Ember.$.getJSON('http://localhost/EmpDir/app/jsonRes/jsonR/'+text);
}
});

But it is not work as i expected

how can i change last part of my JSON url depending on user input?




Aucun commentaire:

Enregistrer un commentaire