无法从angularjs中的restful web服务中提取数据

时间:2014-08-30 12:16:25

标签: javascript html angularjs

我的html页面

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8">

<title>Invoice Automation</title>



<!-- CSS -->

    <link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />





<!-- JavaScripts-->

<script type="text/javascript" src="style/js/jquery.js"></script>

<script type="text/javascript" src="style/js/jNice.js"></script>

<script src="angular.min.js"></script>
<script src="controllers.js"></script>


</head>



<body ng-app="helloApp" ng-controller="HttpController">

    <div id="wrapper" >

         <header id='banner'>

            <h1>Invoice Automation tool</h1>

         </header>





        <ul id="mainNav">

            <li><a href="#" class="active">USERS</a></li>

            <li><a href="#">EMAILS</a></li>

            <li><a href="#">ROLES</a></li>

            <li><a href="#">APPROVALS</a></li>

            <li><a href="#">HIERARCHY</a></li>

            <li class="logout"><a href="#">PREFERENCES</a></li>

            <li class="logout"><a href="Login Page V2.html">LOGOUT</a></li>

        </ul>





        <div id="containerHolder" >

            <div id="container" >

                <div id="sidebar" >

                    <ul class="sideNav">

                        <li><a href="#" class="active">Users details</a></li>

                        <li><a href="Create User.html" >Create Users</a></li>

                    </ul>

                </div>    



                <!-- // #sidebar -->





                <!-- h2 stays for breadcrumbs -->

                <h2><a href="#">Users</a> &raquo; <a href="#" class="active">User details</a></h2>

             <div >

                <form>



    <div id="main" >

             <form action="" class="jNice">

            <ul id="subnav">

                <li><a href="#">New</a></li>

                <li><a href="#" class="active">View</a></li>

                <li><a href="#">Edit</a></li>

                <li><a href="#">Delete</a></li>

            </ul>           

            <TABLE>

               <TR>

                  <TD></TD>

                  <TD><strong>Email Account </strong></TD>

                  <TD><strong>First Name</strong></TD>

                  <TD><strong>Last Name</strong></TD>

                  <TD><strong>Active from</strong></TD>

                  <TD><strong>Active to</strong></TD>

               </TR>

               <TR ng-repeat="profile in profiles">

                  <TD><input type="checkbox"></TD>

                  <TD><p>{{profile.id}}</p></TD>

                  <TD>{{profile.createdBy}}</TD>

                  <TD>{{profile.creationDate}}</TD>

                  <TD>{{profile.endDate}}</TD>

                  <TD>{{profile.roleDesc}}</TD>

               </TR>



            </TABLE>    





    </div>

                <!-- // #main -->



                <div class="clear" ></div>

            </div>

            <!-- // #container -->

        </div>  

        <!-- // #containerHolder -->

     <p id="footer">Home</p>

    </div>

    <!-- // #wrapper -->

</body>

</html>

我的控制器文件是

var helloApp = angular.module("helloApp", []);
helloApp.controller("HttpController", [ '$scope', '$http',
    function($scope, $http) {
        $http({
            method : 'GET',
            url : '/roles/listall'
        }).success(function() {
            $scope.profiles = data;
        }).error(function() {
            alert( "failure");
        });
} ])

当我试图通过浏览器显示时,我无法从服务器中提取数据。它没有显示实际数据,而是显示如下所示的硬编码数据

**Email Account First Name  Last Name   Active from    Active to

{{profile.id}} {{profile.createdBy}} {{profile.creationDate}} {{profile.endDate}} {{profile.roleDesc}} **

1 个答案:

答案 0 :(得分:0)

您的成功回调是否获得了数据?尝试在控制台中记录它以供参考?

可能你可以试试这个,因为回调是签名中的数据。

    }).success(function(data) {
        console.log(data);
        $scope.profiles = data;
      }