php - 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函数中查看...
解决方案
通过使用$scope解决
return TableState.renderTable($scope, tableState, MyCall.getRecipientPositions(tableState, $scope.id));
并删除属性中的调用;
app.controller('MyController', ['$scope', 'MyCall','TableState', function ($scope, MyCall,TableState) {
推荐阅读
- javascript - 如何为引导模式内的 ng-select 添加自动对焦
- javascript - 使用 JavsScript 将宽度设置为跨度不起作用
- api - 如何将相机捕获的图像传递到服务器?
- node.js - 在 Async-Await 中的 Await 处永远停止
- sql - 将 Crystal Reports 连接到 SQL Server 时出现问题
- bash - ffmpeg 将音频混合代码组合成复杂的连接脚本
- linux - 如何在 Apache2 中重定向到 https
- javascript - 使用 JS 为背景 url 创建一个 const 以更改背景
- c++ - 我的 cpp 程序输出错误
- c# - 如何使用 iText7 将 .p7s 字节数组插入 PDF?