rel*_*lez 5 angularjs angularjs-controller
我试图隐藏/显示基于Controller布尔变量的表单的一部分.这是我的HTML代码:
<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>
Run Code Online (Sandbox Code Playgroud)
我创建了一个函数,根据发送的值将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;
}
}]);
Run Code Online (Sandbox Code Playgroud)
知道我错过了什么吗?
谢谢!
| 归档时间: |
|
| 查看次数: |
21494 次 |
| 最近记录: |