How to handle AngularJs with an asp.net web form?

I am just embedding AngularJs on a website written in asp.net web forms.

I find out when the button is ng-Submiton the button, the form also makes a post call.

How to stop formfrom submittingand angular do its work.

My sample code is below.

<form id="form1" runat="server">
   <div >
     <input type="text" data-ng-model="enteredName" ng-model-instant/>
     <button class="btn" value="add" data-ng-submit="addName()" >Add</button>
   </div>
</form>


//Add Name function
$scope.addName = function () {
   $scope.names.push($scope.enteredName);
   $scope.enteredName = '';
};

Note : The ng-submit controller is working fine it is adding the input to the string list but after that form makes post call. and page go to IsPostBack.

Someone help me process the form without sending messages.

+4
source share
2 answers

angular .NET, , , .NET MVC - .NET. , - <form>, . , - Visual Studio, :

<form runat="server" ID="Form1">

, webforms, <asp:LinkButton> , "" HTML, <input>, . , -, , - . , , , .

,.NET MVC , HTML- , postbacks viewstates. , -, angular, angular , - .NET.

+1

ng-click ng-submit. asp.net , angular.

0

All Articles