我遇到了问题,我无法理解其中的原因,因为它可以在本地服务器上运行,但在生产中却没有。
我有这样的指示:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
在我的控制器中我有休闲:
calcP.directive('modalDialog', function() {
return {
restrict: 'E',
scope: {
show: '=',
types: '=',
},
replace: true,
transclude: true,
link: function(scope, element, attrs) {
console.log('scope', scope);
scope.dialogStyle = {};
if (attrs.width)
scope.dialogStyle.width = attrs.width;
if (attrs.height)
scope.dialogStyle.height = attrs.height;
scope.hideModal = function() {
scope.show = false;
delete scope.types.individual;
};
},
template: "<div class='ng-modal' ng-show='show'><div class='ng-modal-overlay' ng-click='hideModal()'></div><div class='ng-modal-dialog' ng-style='dialogStyle'><div class='ng-modal-close' ng-click='hideModal()'>X</div><div class='ng-modal-dialog-content' ng-transclude></div></div></div>"
};
});
在视图中我有休闲:
$scope.modalShown = false;
$scope.toggleModal = function() {
$scope.modalShown = !$scope.modalShown;
console.log('modalShown', $scope.modalShown);
};
因此,就我看到使用console.log而言,toggleModal()并不起作用。
答案 0 :(得分:0)
你能试试吊装功能吗?
而不是直接函数赋值给$ scope
//what you did
$scope.toggleModal = function() {
$scope.modalShown = !$scope.modalShown;
console.log('modalShown', $scope.modalShown);
};
尝试单独定义函数并将其分配给$ scope,如
$scope.toggleModal = toggleModal;
function toggleModal () {
$scope.modalShown = !$scope.modalShown;
console.log('modalShown', $scope.modalShown);
};