0

我有一个索引页

<body ng-controller="MasterCtrl">
  <div id="page-wrapper" ng-class="{'open': toggle}" ng-cloak>

    <!-- Sidebar -->
    <div id="sidebar-wrapper" ng-controller="SidebarCtrl">
         <ul class="sidebar">
            <li>
                **<a href="#/nextpage?team={{department_name}}">Page Lik data <span class="menu-icon fa fa-road"></span></a>**
            </li>
         </ul>
    </div>
  </div>
  <!-- Main Content -->
    <div ui-view></div>
</body>

我们从http://localhost:3000/employees?employee_id=764967674获得的员工数据是

[
{
location: "BLR",
department: "Core",
designation: "desig",
name: "Mr X",
gender: "M",
employee_id: 764967674,
email: "thisidas@example.com",
mobile: 7654578882,
_id: "5atsda5sdasd",
}
]

sidebar_ctrl:

/**
 * sidebar  Controller
 */

 angular.module('tool')
 .controller('SidebarCtrl', ['$scope', '$cookieStore', 'Employee', '$window', '$stateParams', '$log', SidebarCtrl]);

 function SidebarCtrl($scope, $cookieStore, Employee, $window, $stateParams, $log) {

    $scope.emp_id =  $stateParams.emp_id

    if($scope.emp_id) {
        var employee_Data = Employee.query({employee_id: $scope.emp_id}, function() {           
            $scope.department_name = employee_Data[0].department;
            alert("asd");   
        });
    }

}

员工服务是

angular.module('PdbTool')
  .factory('Employee', ['$resource', Employee]);

  function Employee($resource) {  

       return $resource('localhost:3000/employees?', { employee_id: '@id' }, {
         query: {method:'GET', isArray: true},
 });
}

还有另一个使用相同服务的 ng-controller

/**
 * Profile  Controller
 */

 angular.module('PdbTool')
 .controller('ProfileCtrl', ['$scope', '$cookieStore', 'Employee', '$window', '$stateParams', '$log', ProfileCtrl]);

 function ProfileCtrl($scope, $cookieStore, Employee, $window, $stateParams, $log) {

    $scope.emp_id =  $stateParams.emp_id

    if($scope.emp_id) {
        var entries = Employee.query({employee_id: $scope.emp_id}, function() {             
            $scope.emp_name = entries[0].name;
            $scope.emp_department = entries[0].department;
            $scope.emp_location = entries[0].location;
            $scope.emp_designation = entries[0].designation;
            $scope.emp_email = entries[0].email;    
        });
    }

}

在员工模板 html 中

<tr>
                                            <th>Designation</th>
                                            <td>{{emp_designation}}</td>
                                        </tr>
                                        <tr>
                                            <th>Department</th>
                                            <td>{{emp_department}}</td>
                                        </tr>

这些值是人口,但在侧边栏中

页面喜欢数据

数据不显示?用于 url 重定向

4

0 回答 0