2014-08-30 259 views
0

我的HTML頁面無法拉從寧靜的web服務的數據角JS

<!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}} **

+0

控制檯中是否有錯誤?你嘗試在'$ http'調用之外初始化'$ scope.profiles'嗎?您的REST調用是否實際返回數據? – 2014-08-30 13:05:03

+0

在您的最新更新之後,它看起來像角沒有在這裏運行。在您的控制檯中查找錯誤。 – Ash 2014-08-30 13:25:38

+0

是你的根文件夾中的angular.min.js和constrollers.js文件嗎? – Ash 2014-08-30 13:29:30

回答

0

您的成功回調獲取數據?嘗試將其記錄在控制檯中供您參考?

也許你可以試試這個,因爲回調是簽名中的數據。

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

我試着用的代碼,但它沒有爲我工作 – 2014-08-30 12:50:47

+0

你試過console.log(數據);看看你是否收回任何東西。 – Ash 2014-08-30 12:54:08

+0

沒有我沒有得到任何回 – 2014-08-30 13:01:37