2017-01-03 2 views
1

Im derzeit an einem proyect als Junior-Programmierer arbeiten, ich mit dieser Hilfe brauchen ..Angular bearbeiten Service Laravel Rest api

var vm = diese // winwin in diesem Controller

I‘ m versuchen, einen vorhandenen Beitrag zu bearbeiten, ‚Beiträge‘ ist ein Array mit einem Element ‚Inhalt‘ in der es, mit dem Post Körper, das ist, was ich versucht:

BEITRÄGE JSON:

[ 
    { 
     "id":40, 
     "reference_id":101, 
     "type":"WINWIN", 
     "user_id":1, 
     "title":null, 
     "content":"editado", 
     "canceled":0, 
     "allow_voting":0, 
     "sticky":0, 
     "sticky_date":null, 
     "up_votes":0, 
     "down_votes":0, 
     "media_id":null, 
     "created_at":"2017-01-03 20:20:26", 
     "updated_at":"2017-01-03 20:20:26" 
    } 
] 

HTML :

<md-button ng-click="winwin.editPost(posts.content)" aria-label="edit"> 
         editar 
</md-button> 

HTML TMPL:

<div layout="column" class="credentials"> 
    <md-input-container class="md-block"> 
     <label>Editar post..</label> 
     <textarea class="editarPost" name="post" ng-model="winwin.winwin.posts.content" d-no-asterisk rows="3" md-select-on-focus></textarea> 
     <md-button class="submit" ng-click="winwin.edit">SUBMIT</md-button> 
    </md-input-container> 
</div> 

WINKEL REGLER:

vm.editPost = function(post) { 
      $mdDialog.show({ 
       controller: EditPostController, 
       controllerAs: 'vm', 
       templateUrl: 'app/winwin/modal-edit-winwin-post.tmpl.html', 
       parent: angular.element($document.body), 
       clickOutsideToClose:true, 
       locals: { 
        post: vm.posts.content 
       } 
      }) 

     } 
    } 

    /** @ngInject */ 
    function EditPostController($http){ 
     var vm = this; 

     vm.post = ''; 

     vm.edit = function(post){ 
     $http.push(post) 
     } 

    // vm.item_post = item_post; 
    // vm.edit = function(item_post){ 
    //  $scope.post=''; 
    //  $scope.$apply(function($scope){ 
    //   $scope.post=evt.target.result; 
    //  }); 
    // } 
    } 

Laravel SERVICE:

public function editPost(Request $request) { 
     $winwin = winwin::find($request['content']); 
     if ($request->has('content')) { 
      $winwin->post = $request->input('content'); 
     } 
    } 

Dank im Voraus

Antwort

0

Winkelregler

vm.editPost = function(postContent) { 
       $mdDialog.show({ 
        controller: EditPostController, 
        templateUrl: 'app/winwin/modal-edit-winwin-post.tmpl.html', 
        parent: angular.element($document.body), 
        clickOutsideToClose:true, 
        locals: { 
         post: postContent 
        } 
       }); 
    function EditPostController($scope,$http, $mdDialog, post) { 
       $scope.posts.content= post; 
       $scope.edit = function(post){ 
        $http.push(post) 
       } 
       } 

      } 


     }