javascript - Revert ng-model value in Angular JS -
is possible revert model value when displaying it?
my controller has property:
this.config = {client: false, name: true};
and want use values this:
<label> <input ng-model="ctrl.config.client"> client </label> <div ng-hide="ctrl.config.client">client</div>
i'd show input checked when config.client value false. how can it?
update: if want check checkbox, , use $scope
can use ng-true-value="false"
, ng-false-value="true"
revert default values. works only, if use $scope
instead of this
! here example:
<body ng-app="app"> <div ng-controller="ctrl"> <label> <input type="checkbox" ng-model="config.client" ng-true-value="false" ng-false-value="true"> </label> <div ng-hide="config.client">client</div> </div> <script> angular.module('app', []).controller('ctrl', function($scope) { $scope.config = {client: false, name: true}; }); </script> </body>
and plunker try it: http://plnkr.co/edit/vrizmb2cpdqakhu91yhn?p=preview
Comments
Post a Comment