You must use the ng-model directive for your input element.
Markup
<input type="text" name="name" ng-model="post.PostId" /> <button ng-click="getById(post.PostId)"></button> <h1>{{post.Title}}</h1>
This will bind the two-way model to your post.PostId property. Your ng-click directive will select the correct value entered in the input element.
See my working plunk :)
source share