簡體   English   中英

lalavel rest api的角度編輯服務

[英]Angular edit service to laravel rest api

我目前正在作為一名初級程序員工作,我需要一些幫助。

var vm = this //此控制器中的winwin

我正在嘗試編輯現有的帖子,'帖子'是一個內置項目'內容'的數組,包含帖子正文,這就是我嘗試過的:

POSTS 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>

角控制器:

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服務:

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

提前致謝

角度控制器

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)
                }
              }

          }


      }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM