Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a model BOOK that will insert the book details through angularjs controller

Here is my view:

<h1 align="center">Books</h1>
<div ng-controller="BooksCtrl" class="container">
  <div class="row-fluid">
    <div class="col-md-6"> 
      <form ng-submit="addBook()" class="loginform cf">
        <input type="text" ng-model="newBook.title" placeholder="Title of the Book" required>
        <input type="text" ng-model="newBook.isbn" placeholder="ISBN Number of Book" required>
        <input type="file" ng-model="newBook.book_link">
        <input type="text" ng-model="newBook.edition" placeholder="Edition of the book" required>
        <input type="text" ng-model="newBook.publication_id" placeholder="Select the publication ID" required>
        <input type="submit" value="Add Book">
      </form>

      <div ng-show="editorEnabled" class="loginform cf">
        <form ng-submit="update()">
          <input type=text ng-model="editableBook.title" ng-show="editorEnabled" required>
          <input type=text ng-model="editableBook.body" ng-show="editorEnabled" required>
          <input type="submit" value="Update" class='btn'>
          <a href="#" ng-click="disableEditor()" class="btn">close</a>
        </form>
      </div>
      <div ng-show="selectedBook" class="loginform cf">
        <h2>{{selectedBook.title}}</h2>
        <p>{{selectedBook.body}}</p>
      </div>
    </div>

    <div class="col-md-6">
      <ul style="list-style-type: none;">
        <li ng-repeat="book in books" class="loginform cf" >
          <div>
            <div>{{book.title}}</div>
            <a href="">
              <img src="{{book.book_link.thumb.url}}"/>
            </a>


            <button href="#" ng-click="showBook(book)" class="btn">Show</button>
            <button href="#" ng-click="enableEditor(book)" class="btn">edit</button>
            <br>
          </div>
        </li>
      </ul>
    </div>

  </div>
</div>

My angularjs Controller function is:

book = Book.save($scope.newBook, function(data,headers) {
        console.log(book);
        $scope.books.push(book);
    }, function(data,headers) {
        // do the error case  
        console.log(data);
        if (data.status == 422)
        {
            alert("validation is failed book should be unique");
        }           
    });

The problem is that it is storing all the details except the book pdf upload. It is not passing even the name. How can I solve this? Any Suggestions would be appreciated.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.