我喜欢使用angular ui bootstrap插件将数据从1个视图(主视图)传递到模态视图,下面是我的代码似乎不起作用:
主视图
vm.receipt_id = "1234"
调节器
vm.alertMeJimmy = function(receipt_id) { $uibModal.open({ animation: true , templateUrl: '/cashier/views/cashier.angular_components.modal', controller: 'PatientsController', controllerAs: 'vm', resolve: { receipt_id : function () { return receipt_id ; } }, size: 'lg' }); }
模态视图
我希望在我的模态视图中像下面一样访问它
返回一个对象而不是一个原语:
angular.module('App').controller('Controller', [ '$uibModal', function ($uibModal) { var vm = this; vm.receipt_id = 1234; vm.alertMeJimmy = function (receipt_id) { var modalInstance = $uibModal.open({ size: 'sm', templateUrl: 'modal.html', controller: 'Modal as vm', resolve: { 'receipt': { id: receipt_id } } }); } } ]); angular.module('App').controller('Modal', [ 'receipt', function (receipt) { var vm = this; vm.receipt = receipt; } ]);
关于Plunker的例子:http://plnkr.co/edit/d9RLJLHr1zr9d5gVKHpD?p = preview