首页 > 解决方案 > AngularJS 检索在控制器中的刀片处初始化的数据

问题描述

我在 Laravel Blade 中有一个表,它初始化了一个我想在控制器中访问的值,以便发送给一个函数进行 API 调用。问题是我如何访问发送的 ID

app.controller('MyController', ['$scope', 'MyCall','id','TableState', function ($scope, MyCall, id,TableState) {

    $scope.displayed = [];

    $scope.callServer = function callServer(tableState)
    {
        return TableState.renderTable($scope, tableState, MyCall.getRecipientCalls(tableState, $scope.id));
    };

}]
);

我的刀片代码

<div ng-controller="MyController" ng-init="id ='{!! $mycalls->id !!}'">

想将上面的 id 传递给控制器​​并在getRecipientCalls函数中查看...

标签: phpangularjslaravelsmart-table

解决方案


通过使用$scope解决

return TableState.renderTable($scope, tableState, MyCall.getRecipientPositions(tableState, $scope.id));

并删除属性中的调用;

app.controller('MyController', ['$scope', 'MyCall','TableState', function ($scope, MyCall,TableState) {

推荐阅读