0
私は、getCurrentUser権限で返された値を取得しようとしています。関数を呼び出すと、私はこのリソースにPromiseを保持します。私はそこに_idの値を見ることができます!どのように私はそれにアクセスするのですか?NodeとAngularを使用して値の代わりにResourceオブジェクトを受け取ります。
ありがとうございます! Console Output
ここGETCURRENTUSERが定義されている認証サービスのビットです:私はそれを呼び出すのはここ
(function config() {
function AuthService($location, $http, $cookies, $q, appConfig, Util, User) {
const safeCb = Util.safeCb;
let currentUser = {};
let Auth = {};
const LOCAL_HOST = 'localhost';
if ($cookies.get('token') && $location.path() !== '/logout') {
currentUser = User.get();
}
Auth = {
getCurrentUser(callback) {
if (arguments.length === 0) {
return currentUser;
}
const value = currentUser.hasOwnProperty('$promise') ? currentUser.$promise : currentUser;
return $q.when(value).then(user => {
safeCb(callback)(user);
return user;
},() => {
safeCb(callback)({});
return {};
});
}
...
は次のとおりです。
angular.module('toroApp').directive('csvreaderDirective', ['$http', function ($http, Auth) {
return {
controller(Auth) {
const currentUser = Auth.getCurrentUser();
console.log(currentUser);
},
compile(element, Auth) {
...
urコードを表示してください。 – Wcan