i have a problem, Here my code
-
You should use $scope.$watch to keep a look on the $scope.check
variable. Once user click the checkbox, watchCheck would be invoked. Since you have defined the ng-true-value
as "Yes", you have to check the checked ==== 'Yes'
when the $scope.check
changes.
$scope.$watch('check', function watchCheck(checked) {
if (checked === 'Yes') {
$scope.nama1=$scope.nama;
$scope.telephone1=$scope.telephone;
}
});
讨论(0)
-
Here is the plunker http://plnkr.co/edit/G4H4YfwTKO1jmiFDFIu6?p=preview
var pesan = angular.module("pesan", []);
pesan.controller("datapesan", function($scope){
$scope.$watch('check',function(){
if($scope.check){
$scope.nama1=$scope.nama;
$scope.telephone1=$scope.telephone;
}
});
});
讨论(0)
-
Try this one;
var pesan = angular.module("pesan", []);
pesan.controller("datapesan", function($scope){
$scope.$watch('check',function(){
if($scope.check === 'Yes'){
$scope.nama1=$scope.nama;
$scope.telephone1=$scope.telephone;
} else {
$scope.nama1='';
$scope.telephone1='';
}
});
});
讨论(0)