大佬教程收集整理的这篇文章主要介绍了显示/隐藏基于Controller布尔变量的AngularJS元素,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<div id="sheetform-container" ng-controller="SheetController as SheetCtrl"> <form action="#"> <div class="sheetform-row" ng-show="canShow('Price')"> <div class="sheetform-left-col fl-left"><label for="sheetform-price">Price</label></div> <div class="sheetform-midlle-col fl-left"><input type="text" class="sheetform-input" id="sheetform-price" name="price" value="$0.00" /></div> <div class="sheetform-right-col fl-right"></div> </div> </form> </div>
我创建了一个函数,根据发送的值将Price属性更改为true / false,称为setConfig.这是Controller代码的样子:
ngApp.controller('SheetController',['$scope',function($scopE) { $scope.Price = true; $scope.canShow = function(field) { return $scope.Price; } $scope.setConfig = function(config) { $scope.Price = config.Price; } }]);
知道我错过了什么吗?
谢谢!
<div id="sheetform-container" ng-controller="SheetController as SheetCtrl"> <form action="#"> <div class="sheetform-row" ng-show="showPrice"> <div class="sheetform-left-col fl-left"><label for="sheetform-price">Price</label></div> <div class="sheetform-midlle-col fl-left"><input type="text" class="sheetform-input" id="sheetform-price" name="price" ng-model="price" /></div> <div class="sheetform-right-col fl-right"></div> </div> </form> </div>
ngApp.controller('SheetController',function($scopE) { $scope.showPrice = true; $scope.price = null; }]);
我不确定你是如何确定价格是否应该显示但你可以将$scope.showPrice分配给一个属性,无论该形式是什么对象,或者如果它是一个切换,那么你可以说:
<a href ng-click="showPrice = !showPrice"></a>
以上是大佬教程为你收集整理的显示/隐藏基于Controller布尔变量的AngularJS元素全部内容,希望文章能够帮你解决显示/隐藏基于Controller布尔变量的AngularJS元素所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。