O'Reilly logo
  • Patrick S thinks this is interesting:

The ng-model directive hooks an input to a $scope property. Now if you access $scope.postBody inside the controller, you’ll get the data inside this text field.

To use this instead of your stock data, update the addPost() function like so:

$scope.addPost = function () {
  $scope.posts.unshift({
    username: 'dickeyxxx',
    body: $scope.postBody
  })
}