Angular指令不显示任何值(Angular directive not displaying any values)
我有这个没有显示任何值的指令,即使在我打破函数时,vm变量在创建每个指令行时都有。
(function () { angular .module('sales.directives') .directive("viewPayment", viewPayment); function viewPayment() { return { controller: 'ViewPaymentController', controllerAs: 'vm', bindToController: true, templateUrl: 'pages/viewPayment.html', restrict: 'E', scope: { payment: '=', paymentDetails: '=', setCurrentPayment: '&', currentPaymentId: '=', openLineItemDrawer: '&' } }; } angular .module('sales') .controller('ViewPaymentController', viewPaymentController); viewPaymentController.$inject = ['$scope']; function viewPaymentController($scope) { var vm = $scope; vm.details = _(vm.paymentDetails).where({ 'paymentId': vm.payment.paymentId }).value(); vm.revisionCount = getPaymentCount(); vm.showRevision = vm.revisionCount > 0; vm.isCurrentPayment = false; vm.showEffectiveDate = vm.payment.paymentType === 'ePayment'; $scope.$watch('vm.currentPaymentId', setIsCurrentPayment); function getPaymentCount() { return vm.details.length - 1; } function setIsCurrentPayment(currentPaymentId) { vm.isCurrentPayment = currentPaymentId === vm.payment.paymentId; } } })();I have this directive that is not showing any values, even though when I break on the function, the vm variable has everything when each directive row is created.
(function () { angular .module('sales.directives') .directive("viewPayment", viewPayment); function viewPayment() { return { controller: 'ViewPaymentController', controllerAs: 'vm', bindToController: true, templateUrl: 'pages/viewPayment.html', restrict: 'E', scope: { payment: '=', paymentDetails: '=', setCurrentPayment: '&', currentPaymentId: '=', openLineItemDrawer: '&' } }; } angular .module('sales') .controller('ViewPaymentController', viewPaymentController); viewPaymentController.$inject = ['$scope']; function viewPaymentController($scope) { var vm = $scope; vm.details = _(vm.paymentDetails).where({ 'paymentId': vm.payment.paymentId }).value(); vm.revisionCount = getPaymentCount(); vm.showRevision = vm.revisionCount > 0; vm.isCurrentPayment = false; vm.showEffectiveDate = vm.payment.paymentType === 'ePayment'; $scope.$watch('vm.currentPaymentId', setIsCurrentPayment); function getPaymentCount() { return vm.details.length - 1; } function setIsCurrentPayment(currentPaymentId) { vm.isCurrentPayment = currentPaymentId === vm.payment.paymentId; } } })();最满意答案
删除“controllerAs”并更改所有vm。 到范围。 解决了这个问题。
Removing the "controllerAs" and changing all of the vm. to $scope. fixed the issue.
更多推荐
发布评论