我有一个表格,您可以在其中创建患者。在该表单上,我有一个用于分配设备的输入框和一个用于打开显示设备列表的弹出窗口的按钮。我对列表中的每个设备都有一个按钮。当我单击列表中的设备之一时,我希望设备编号打印在患者创建页面的输入框中。
一、患者创建页面
$scope.openDeviceModal = function () {
var notifyModalInstance = $uibModal.open({
size: 'sm',
component : 'deviceModalComponent'
});
notifyModalInstance.result.then(function (result) {
alert(result);
});
}
单击选择设备后,将打开模式。这是它的样子
我有 html 和控制器文件
<table>
<thead>
<tr><th>Device Serial number</th></tr>
<tr><th>Status</th></tr>
<tr><th>Action</th></tr>
</thead>
</table>
<table class="table table-inverse">
<tbody>
<tr ng-repeat="device in devices">
<td width="12%" ><span>{{device.deviceSerialNumber}}</span>
</td>
<td width="10%" ><span>{{device.assignmentStatus}}</span>
</td>
<td width="12%">
<button type="submit" class="btn btn-primary pull-right"
ng-click="selectThisDevice(device);"><span
title="Select Device"
class="glyphicon glyphicon-plus"></span> Assign
</button>
</td>
</tr>
</tbody>
</table>
控制器有一个功能 selectThisDevice
define([], function () {
'use strict';
var deviceModalComponent = {
templateUrl: 'views/components/patient/create/deviceModal/deviceModal.html',
controller: [
'$scope',
'AuthService',
'DeviceDataService',
'device_map',
'$rootScope',
function ($scope, AuthService, DeviceDataService, device_map,
$rootScope, $uibModalInstance) {
$scope.selectThisDevice = function (device) {
console.log("Device Info ------"+JSON.stringify(device));
$uibModalInstance.close(device.deviceSerialNumber);
}
}
]
}
return deviceModalComponent;
});
当我在函数中记录设备对象时,它看起来很好。但是对于关闭方法,它说“无法读取未定义的属性'关闭'”。我想将设备序列号发送回患者创建控制器。我是新来的。有人可以帮我吗谢谢