我正在从刀片模板传递数组“ slot”,并希望在js文件中获取其值,例如name = slot ['name'];。

时间:2019-03-18 05:03:40

标签: javascript laravel laravel-blade

我有这个刀片代码,想在calender.js的validateSlot函数中获取$ slot数组中name的值。如何获得?

我的Js功能代码:

$scope.validateSlots = function(x) {
  namee = x['name'];


  return true;
};
**And this is my Blade file's code :** 

<div class="table-row table-body" ng-if="validateSlots.apply(this, slot)">
  <div class="user-column table-cell">
    <a class="center-vertically" href="{{route(" worker-profile ", [$slot['id']])}}">
      <div title="{{isset($slot['service_string'])?$slot['service_string']:''}}">

        {{$slot['name']}}
        <span class="total-hours ">
                                                            <span>

                                                            </span>
        </span>

      </div>
    </a>
  </div>

1 个答案:

答案 0 :(得分:0)

尝试一下:

$scope.validateSlots = function(x) {
  name = "{{$slot['name']}}"; //array from your controller etc to blade JS file
  return true;
};