title: AngularJS - Form with Select element to get Id from another object
body: <p>I have a two tables "Category" and "Publication" with a One to Many relationship.</p>
  
  <p><strong>Category:</strong> id, name, description</p>
  
  <p><strong>Publication:</strong> id, title, content, category_id</p>
  
  <p>And I need to get the category id through a select element and put it in the category_id field.</p>
  
  <p>Publication form:</p>
  
  <pre><code>&lt;form&gt;
    &lt;input type="text" ng-model="publication.title" placeholder="Title" /&gt;
    &lt;input type="text" ng-model="publication.content" placeholder="Content" /&gt;
    &lt;!-- Here is my problem because I can list all categories but I can't get the category id and put it in the category_id field --&gt;
    &lt;div ng-init="categories()"&gt;
      &lt;select class="form-control" ng-model="category" ng-options="category.name for category in categories"&gt;
          &lt;option value=""&gt;-- Select category --&lt;/option&gt;
      &lt;/select&gt;
     &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my controller to get all categories:</p>
  
  <pre><code>$scope.categories = function() {
      $http(
              {
                  method : 'GET',
                  url : '/prodemo/category'
              }).success(
                      function(data, status, headers, config) {
                          $scope.categories = data;
              }).error(
                      function(data, status, headers, config) {
              });
  };
  </code></pre>
  
  <p>How can I do it?</p>