javascript - AngularJs complex model based on drop down selection -
not having lot of experience complex angular js models, i'd ask advice or help. please @ following picture. shows i'm trying accomplish.
i need store number of patients center each year in drop down. when select year, input fields should blank (or populated data db). when switch 2012, input data should still present. data should submitted when button pressed.
i have hard time figuring out how model , data binding should like. ideas appreciated.
hopefully try may idea you. please have it.
plunker: http://plnkr.co/edit/ndrk1uaoe0dkrhfssguh?p=preview
code:
$scope.qty = 1; $scope.cost = 2; $scope.incurr = 'eur'; $scope.currencies = ['usd', 'eur', 'cny']; $scope.usdrates = [ { quantity:0,cost:0}]; $scope.change = function() { if($scope.usdtoforeignrates === 'usd') { $scope.usdrates[0].quantity = 25; $scope.usdrates[0].cost = 30; $scope.qty =$scope.usdrates[0].quantity; $scope.cost = $scope.usdrates[0].cost; } if($scope.usdtoforeignrates === 'eur') { $scope.usdrates[0].quantity = 45; $scope.usdrates[0].cost = 40; $scope.qty =$scope.usdrates[0].quantity; $scope.cost = $scope.usdrates[0].cost; } if($scope.usdtoforeignrates === 'cny') { $scope.usdrates[0].quantity = 55; $scope.usdrates[0].cost = 50; $scope.qty =$scope.usdrates[0].quantity; $scope.cost = $scope.usdrates[0].cost; } };
}]);
Comments
Post a Comment