Pushkar Jaju
Pushkar Jaju

Reputation: 639

How to Bind Value from 1 textbox to another textbox in C# using AngularJS

When user enters any value in one textbox the same value should get populated in another texbox, i tried below one but not working.Please suggest.

<title></title>
<script src="Scripts/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('myCntrl', function ($scope) {
    $scope.txt1 = "AngularDemo";
});
</script>
<body>
    <form id="form1" runat="server" ng-app="myApp">
        <div data-ng-controller="myCntrl">
            <asp:TextBox ID="TextBox1" runat="server" ng-model="txt1"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server" ng-bind="txt1" Text="{{txt1}}" style="border-color:{{txt1}}"></asp:TextBox>                        
        </div>
    </form>
</body>
</html>

Upvotes: 1

Views: 618

Answers (1)

Deblaton Jean-Philippe
Deblaton Jean-Philippe

Reputation: 11398

Just use ng-model everywhere

<form id="form1" runat="server" ng-app="myApp">
    <div data-ng-controller="myCntrl">
        <asp:TextBox ID="TextBox1" runat="server" ng-model="txt1"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" ng-model="txt1" style="border-color:{{txt1}}"></asp:TextBox>                        
    </div>
</form>

What did you try to achieve with the following : Text="{{txt1}}"

Upvotes: 1

Related Questions