How to get value of input ember

Wanted to get the input value, but looking at the console.log it show that this value is undefined. Anyone here who know how to solve that.

import Route from ‘@ember/routing/route’;

export default Route.extend({ actions: { addProduct: function() { var product = this.get(‘product’); console.log(product); } } });

Product {{input type="text" class="form-control" value=product placeholder="Product Name"}}
<div class="form">
	{{input type="text" class="form-control" value="price" placeholder="Price"}}

<div class="form">
	{{input type="text" class="form-control" value="amount" placeholder="Add Task"}}
<button {{action 'addProduct'}} class="add-button">Submit</button>

I believe there are two separate issues holding you back.

First, you need to remove the quotations surrounding your value attributes. e.g. value=price

Second, you will need to use this.get('controller').get('price') instead of this.get('price')

I have thrown together the following example that should demonstrate a working input.

1 Like

Thanks for helping me!!