Click here to Skip to main content
15,886,713 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using MVC Razor View with AngularJS.

I am creating the UserMaster object in controller and passing to the view

VB
Function AddNewUser() As ActionResult
       Dim objUser As New UserMaster()
        Return View("UserMaster", objUserMaster)
End Function


In View, By using HTML helper classes the text box and validation controls will be created
HTML
@<div ng-app ng-controller="UserController">
    @Html.EditorFor(Function(model) model.UserName)
    @Html.ValidationMessageFor(Function(model) model.UserName)

In the client side using the following statement the AngularJS model is created

JavaScript
<script type="text/javascript">
          function UserController($scope, $http) {
          $scope.UserData = @Html.Raw(Json.Encode(Model));
          }
   </script>

The server side validations(which I have written in the UserMaster Class) are working fine in client side, The razor engine is automatically doing that by generating client side validation scripts.

I am automatically getting flourished model in server side after submit.

But I am not able to manipulate/get the model data in client side using AngularJS (by using $scope.UserData.UserName). I want to access the UserName value inside the text box when the user is modifying it by using angular JS.. How?
Posted
Comments
Nathan Minier 3-Sep-14 9:14am    
Is this running in an ng-view?
Vindhyachal_Kumar 4-Sep-14 2:58am    
post the code of AngularJs + routing configuration used in your project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900