Arshi
Arshi

Reputation: 511

Active class on ng-click ( Laravel 4 + Angular JS 1)

I have been looking for an answer for last 4 hours and by gather multiple records I have accomplished few things but it's not working fine. Where am I making a mistake?

View File:

    <?php
    $payment_methods = DB::table('payment_methods')
            ->select('*')
            ->orderBy('created_at', 'desc')
            ->whereNull('deleted_at')
            ->get();
    ?>

    <div style="margin-bottom:20px; display:inline-block;">
              @foreach($payment_methods as $pm)
               <div class=" pay-logo">
                @if($pm->method_name != 'Cash on Delivery')
                    <label>
                      <img class="<% '{{$pm->method_name}}' ==  payment_method ?  'active' : '' %>"     ng-click="selectPayment('{{$pm -> method_name}}')"  src="/assets/marketplace/images/payment/{{$pm -> method_name}}.jpg" alt="" required> 
                      <input style="visibility:hidden;"   type="radio"  name="payment_method"  value="{{$pm->method_name}}"  >
                    </label>
                 @endif
                </div>
             @endforeach
        </div>

Angular JS Code :

$scope.selectPayment = function (payment_meth){
  $http({
         url: "/cart/getInfo?payment_value=" +$scope.payment_method, method: "GET",
       }).success(function (paymentdata){
                if (paymentdata != 'No Description Found'){
                    $scope.payment_value = paymentdata[0];
                    console.log($scope.payment_value.description);
                }
            }).error(function (e){
                console.log(e);
            });
     }

Upvotes: 3

Views: 66

Answers (1)

gianlucatursi
gianlucatursi

Reputation: 680

<img ng-class="{'active': '<% $pm→method_name %>' == payment_method}" ng-click="selectPayment('{{$pm -> method_name}}')"  src="/assets/marketplace/images/payment/{{$pm -> method_name}}.jpg" alt="" required>

Upvotes: 1

Related Questions