【问题标题】:Active class on ng-click ( Laravel 4 + Angular JS 1)ng-click 上的活动类(Laravel 4 + Angular JS 1)
【发布时间】:2017-01-03 03:33:19
【问题描述】:

过去 4 小时我一直在寻找答案,通过收集多条记录,我完成了一些事情,但它无法正常工作。 我在哪里犯错了?

查看文件:

    <?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 代码:

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

【问题讨论】:

  • 你说的“它不能正常工作”是什么意思?您看到了什么错误,您希望看到什么?

标签: php angularjs laravel laravel-4


【解决方案1】:
<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    相关资源
    最近更新 更多