mardi 20 février 2018

How to fetch single data in Angularjs with Laravel5

I faced issue while retreving single row/ data from angular to html. I need to print the title. Below is the code of angular controller (partial):

    vm.showJoke = function(joke){
  console.log(joke);

  $http.get('http://localhost:8000/api/v1/jokes/' + joke, {
        //body: joke.joke,
        //user_id: $rootScope.currentUser.id
        //user_id: localstorageUser.role_id
    }).success(function(response) {
      //console.log(response.data.joke);
      vm.jokes_show = response.data.joke;
      console.log(vm.jokes_show);
        $scope.MessageAll = 'Joke shows! ';
    }).error(function(){
      console.log("error");
      $scope.MessageAll = 'Please try again';
    });
}

Below is my HTML codes:

<span ng-hide="showEnabled">
                <a href="#jokes" ng-click="showEnabled=!showEnabled"><span class="glyphicon glyphicon-th-large" data-ng-click="jokes.showJoke(joke.joke_id)"></span></a>
            </span>


            <span ng-show="showEnabled" style="background-color:powderblue;">
                    <p style="background-color:powderblue;" ng-model="jokes_show"></p>
            </span>

Your help most welcome.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire