I have a select dropdown that I want to get the current selected value
via the ng:change:
<select class="small" name="invoice.invoice_status"
ng:change="setStatus(invoice.invoice_status)" ng:options="s.id as
s.status_name for s in invoice_statuses"></select>
but upon change, I get the value it was selected before the change
within the setStatus(invoice_status).
so it seems, there is a delay between when the new value is registered
to the model in ng:change().
how can I just get the current new value of the select change event?
without resorting to jquery/etc...
thanks,
jae
http://docs.angularjs.org/#!/api/angular.scope.$watch
Hope this helps.
/Mårten
2011/12/6 jae lee <furi...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to angular+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/angular?hl=en.
>
In 0.10.x you can watch an array. I don't think this was possible in
0.9.x (without resorting to watching a json-formated string of the
array).
Here is an example:
http://jsfiddle.net/aq6SY/
Not sure why I get the entire scope in the watch callback though... bug?
/Mårten
2011/12/7 knrdk <klun...@gmail.com>:
> How would that work when iterating through an array?
>
For example, I wouldn't want to watch all of scope.records, but just
scope.records[].status.
As to watch just some property of objects in array; The watch
expression can be any function, I guess something like this would
work.
scope.$watch(function() {
var statuses = [];
angular.forEach( scope.records, function(record) {
statuses.push(record.status);
});
return statuses;
}, onChangeFn);
/mårten
2011/12/7 knrdk <klun...@gmail.com>:
> Oh neat. Can that be used to watch individual values of an array?
>
> For example, I wouldn't want to watch all of scope.records, but just
> scope.records[].status.
>
2011/12/9 Vojta Jina <vojta...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/angular/-/krYjduMPKCcJ.
Sorry for causing any confusion.
/Mårten
2011/12/10 Misko Hevery <mi...@hevery.com>:
http://docs-next.angularjs.org/api/angular.widget.textarea
http://docs-next.angularjs.org/api/angular.widget.input
http://docs-next.angularjs.org/api/angular.widget.select
/mårten
2011/12/11 Mårten Dolk <marte...@gmail.com>: