hide value checkbox

Seven price
Seven price used Ask the Experts™
on
http://jsfiddle.net/sevensnake/nvrwjd29/

when I type a value in the textbox and check the checkbox I want to remove and when I select the dropdown value then uncheck I want to remove the value.
So I can have either or. Either the textbox value or the select box.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Manager / Solutions Architect
Commented:
I changed your fiddle: http://jsfiddle.net/AlexCode/nvrwjd29/3/
var app = angular.module("MyApp", []);

app.controller("mainController", function ($scope) {

    $scope.$watch('mymodel', function(val){
        if(!$scope.a) return;
        
        if(val){
            delete $scope.a.select;
        } else {
            delete $scope.a.text;
        }
    });
    
});

Open in new window

Seven priceFull Stack

Author

Commented:
looks great. it works in fiddle but watch does not work after load.  can this be a ng-click. may work out better for me.
Alexandre SimõesManager / Solutions Architect

Commented:
Here's the version with the ng-click: http://jsfiddle.net/AlexCode/nvrwjd29/4/
var app = angular.module("MyApp", []);

app.controller("mainController", function ($scope) {

    $scope.chkChanged = function(){
        if(!$scope.a) return;
        
        if($scope.mymodel){
            delete $scope.a.select;
        } else {
            delete $scope.a.text;
        }
    };
});

Open in new window

The difference is not that big and actually like this you keep one watch out of the digest cycle :)
Seven priceFull Stack

Author

Commented:
tks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial