2016-08-29 5 views
0

私はダッシュボードを持っています。私はスーパー管理者です。ユーザープロファイルを作成して、すべてのプロファイルデータを表示できます。今、私はすべてのユーザーのテーブルを持って、私は開いて、必要に応じて、いくつかのユーザーのユーザープロファイルを編集したい。ここ は、ログインしたユーザーのために

<a href="#" class="btn btn-primary btn-block btn-sm" ui-sref="user-profile/:userID">{{'USER_PROFILE'| translate}}</a> 

そして、ここでは、私は今、私はいくつかのユーザーテーブルで選択し、自分のプロフィールを開きたい

.controller('userProfileCtrl', ['$scope', '$stateParams', '$state', '$http','userProfileFactory', 
function ($scope, $stateParams, $state, $http, userProfileFactory) { 
$scope.authentication = authService.authentication; 
$scope.userID = $scope.authentication.userID; 
$stateParams.userID = $scope.userID; 
$scope.user = userProfileFactory.get({user: $stateParams.userID}); 
    $scope.user.$promise.then(function (data){ 
    console.log(data.id); 
    return data; 
}); 

状態のparamsを呼び出すCTRLある)コールユーザープロファイル(のHTMLコードです

<tr ng-repeat="user in users|filter:f" such-href="user-profile/{{user.id}}"> 

そしてこのCTRL

で一部のユーザープロファイルを呼び出します10

そして、ここでは、UIの状態である

.state('user-profile/:userID', { 
       url: '/user-profile/:userID', 
       templateUrl: 'aaaa/aaa/aaaae/user-profile.html', 
       controller: 'aaaaCtrl' 
      }) 

問題がある、私は、ユーザーのプロファイルを開く任意の時間は、私は、プロファイルで(スーパー管理データを)私のデータを取得します。

答えて

0

user_idの$ rootScopeをグローバルに使用するように設定しました。今すぐあなたがログオンしたユーザーを取得するアプリを起動します。

$scope.authentication = authService.authentication; 
$rootScope.user_id = $scope.authentication.userID; 
$scope.user = userProfileFactory.get({user: $stateParams.userID}); 
$scope.user.$promise.then(function (data){ 
    return data; 
}); 

これをhtmlで使用します。

such-href="user-profile/{{user_id}}. 

これでログオンしたユーザーがいます。

管理者に前回と同じようにユーザープロファイルを開くには、代わりにUSERIDを工場で使用します。

<tr ng-repeat="user in users|filter:f" such-href="user-profile/{{user.id}}"> 
関連する問題