Update scope value after dynamically update textbox

Haris

in AngularJS I have scenario that the user selects a value from a grid in a popup and selected value is displayed in textbox in container page. After the user select a value, popup raises an event which is captured in container page. Now I can set the value of textbox using .val() but how do I update Model?

$scope.$on('rowSelectedInPopup', function (event: ng.IAngularEvent, ...data) {
    if (elementId === data[1].toString()) {
        $(elementId).val(data[0].toString());
        $(elementId + "_inlinelbl").html(data[0].toString());
    }
});

Here is my textbox and label html:

<input type="text" value="" id="ServiceManagerglookup" ng-model="Model.Person2.Name" />
<label id="ServiceManagerglookup_inlinelbl" ng-model="Model.Person2.Name">ABC</label>

Please note that textbox can bound with any arbitrary field in scope e.g. Model.AVC.XYZ.LMN

Nicklas Kevin Frank

Besides changing the value you also need to inform Angular that a value changed using

$(elementId).trigger('input');

Like this

$scope.$on('rowSelectedInPopup', function (event: ng.IAngularEvent, ...data) {
    if (elementId === data[1].toString()) {
        $(elementId).val(data[0].toString());
        $(elementId + "_inlinelbl").html(data[0].toString());
        $(elementId).trigger('input');
    }
});

Triggering of this input listener is normally done by the browser - so when you change the model directly you are forced to also trigger the event.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update textbox value $on event

From Dev

Update the a scope value after the $index hit a certain number

From Dev

Update JSON attribute after scope variable update

From Dev

Update TextBox Value on history back

From Dev

GWT CellTable: How to Update A TextBox Dynamically

From Dev

Use a directive to display scope value and update scope

From Dev

AngularJS how to dynamically update part of scope with variable

From Dev

How to dynamically update select value?

From Dev

How to update scope model after operating the filters?

From Dev

how to use the listbox value to update textbox

From Dev

HTML textbox default value update with every input

From Dev

Update textbox value when a button is clicked

From Dev

Entity framework update with textbox.text value

From Dev

I want to update specific textbox value

From Dev

Update textbox value when a button is clicked

From Dev

Update certain column of recordset from textbox value

From Dev

I want to update specific textbox value

From Dev

How can I force a TextBox's DataSource to update after a change in value through code?

From Dev

How can I force a TextBox's DataSource to update after a change in value through code?

From Dev

How do I update an angularjs page after a scope update?

From Dev

Ng-repeat doesn't update after pushing value to array, tried $scope.$apply() but returns error

From Dev

AngularJS Select Value Being Lost After Call to Restful Service and Scope Object Update

From Dev

Not able to update the `scope` value from directive function

From Dev

Update scope value when service data changes

From Java

Update scope value when service data is changed

From Dev

How to update $scope variable value in AngularJs

From Dev

Is there a way to dynamically update block textures after initialization?

From Dev

Is there a way to dynamically update block textures after initialization?

From Dev

Angular $scope not binding to view after update, navigation and $scope.$apply()

Related Related

  1. 1

    Update textbox value $on event

  2. 2

    Update the a scope value after the $index hit a certain number

  3. 3

    Update JSON attribute after scope variable update

  4. 4

    Update TextBox Value on history back

  5. 5

    GWT CellTable: How to Update A TextBox Dynamically

  6. 6

    Use a directive to display scope value and update scope

  7. 7

    AngularJS how to dynamically update part of scope with variable

  8. 8

    How to dynamically update select value?

  9. 9

    How to update scope model after operating the filters?

  10. 10

    how to use the listbox value to update textbox

  11. 11

    HTML textbox default value update with every input

  12. 12

    Update textbox value when a button is clicked

  13. 13

    Entity framework update with textbox.text value

  14. 14

    I want to update specific textbox value

  15. 15

    Update textbox value when a button is clicked

  16. 16

    Update certain column of recordset from textbox value

  17. 17

    I want to update specific textbox value

  18. 18

    How can I force a TextBox's DataSource to update after a change in value through code?

  19. 19

    How can I force a TextBox's DataSource to update after a change in value through code?

  20. 20

    How do I update an angularjs page after a scope update?

  21. 21

    Ng-repeat doesn't update after pushing value to array, tried $scope.$apply() but returns error

  22. 22

    AngularJS Select Value Being Lost After Call to Restful Service and Scope Object Update

  23. 23

    Not able to update the `scope` value from directive function

  24. 24

    Update scope value when service data changes

  25. 25

    Update scope value when service data is changed

  26. 26

    How to update $scope variable value in AngularJs

  27. 27

    Is there a way to dynamically update block textures after initialization?

  28. 28

    Is there a way to dynamically update block textures after initialization?

  29. 29

    Angular $scope not binding to view after update, navigation and $scope.$apply()

HotTag

Archive