Just now breaking into AngularJS and MVC4. My problem is not being able to 
return any data from our local Intranet 2012 Server web api service. Also, 
the project does not error when running in browser. It just does not 
display any data. Help!

 I have a working test service on our local 2012 server which returns JSON 
like so: 

192.168.1.11:8080/api/values

[{"ID":1,"Name":"sankar","Address":"cuttack","DOB":"1983-01-22T00:00:00"},{"ID":3,"Name":"My
 Test Name","Address":"My Test Address","DOB":"1980-01-01T00:00:00"}]

I used Nuget to download and install the latest AngularJS in this new 'empty] 
mvc 4 project.

I'm using VS2012 and MVC project with the following code to pull a simple list 
from the local server like so:

[_Layout.cshtml]
<!DOCTYPE html>
<html lang="en" data-ng-app="">
<head>
<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
 <script src="~/Scripts/angular.min.js"></script>
    <script src="~/Scripts/ValuesController.js"></script>
</head>
<body>
    @RenderBody()
</body>
</html>


[Index.cshtml]
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<script src="~/Scripts/angular.min.js"></script>
    <script src="~/Scripts/ValuesController.js"></script>

<div data-ng-controller="ValuesController">

    <div class="row">
        <h2>Projects and its Tasks</h2>
        <p>Number of Projects : {{ data.length }}</p>
    </div> 

    <div data-ng-repeat="d in data">
        
        <p>Name : {{d.Name}}</p>
    </div>

</div>


I have one ValuesController in this directory (../scripts/ValuesController.js) 
like so:

function ValuesController($scope, $http)
{
    $scope.length = 0;
    $scope.data = [];

    $http.get("192.168.1.11:8080/api/values")
       .then(
           function (result)
           {               
               angular.copy(result.data, $scope.data);
           },
           function ()
           {
               //handle error
           }
       );




}
 


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to