javascript - ng-select AngularJS -
i'm trying put ng select select these quantities:
"splits":[ 1, 2, 3, 4, 5, 6, 8 ], <select ng-options="?" ng-model="ticket_group.quantity" </select> then want show price multiplied quantity have chose
<div style="text-align: center;font-size:25px;"><b> ${{ticket_group.retail_price * ticket_quantity}} usd</b> so reference ng-model this?
please me figure out ng-select , have display final price
ng-model not problem, considering expect $scope.ticker_group.quantity hold value @ end.
what need set ng-options. first of all, options must in scope:
$scope.splits = [ 1, 2, 3, 4, 5, 6, 8 ]; this example. used key (i.e. splits belonged literal object) must ensure object having such key belongs (directly or not) $scope.
following example, splits in scope, can use data-binding expression in ng-options.
ng-options expects key:value specified, syntax is:
ng-options="foo bar (foo, bar) in anobject" so if have object, can iterate keys (properties) , values. notice foo , bar examples (you can use name, being sure such names not reserved words), foo declared in place define keys (i.e. value attribute of each option object), , bar declared in place define labels such options.
as alternative, if iterate array object instead of other classes object, can specify this:
ng-options="foo foo foo in anarray" which generate options having value label (same contents). use them this:
ng-options="val val val in splits" and if have case have array of objects , want specify value , label properties of such objects, like:
$scope.people = [{dni:32111269, nombre:"pepe galleta"}, {dni:11111111, nombre:"nestor kirchner"}, {dni:12345678, name:"mi abuela"}, {dni: 23456789, nombre:"tu hermana"}]; and want make dni value, , nombre label, you'd use:
ng-options="foo.dni foo.nombre foo in people" see more here: https://docs.angularjs.org/api/ng/directive/select
who hold value?: expression set in ng-model directive holder of selected value once use selector.
you want, perhaps, use a:
$scope.$watch('splits', function(v){ ... }); to show price being modified value on splits.
Comments
Post a Comment