这是我的代码:
App.directive('topNav', function(API, $cacheFactory) {
return {
scope: {},
restrict: 'E',
templateUrl: 'packages/partials/includes/header.html',
link: function($scope) {
var cache = $cacheFactory('dataCache');
if( cache !== undefined ) {
API.data().success(function(data){
$scope.phone = data.phone;
$scope.mail = data.email;
cache.put('data', data);
});
} else {
$scope.phone = cache.get('data').phone;
$scope.mail = cache.get('data').email;
console.log(cache.get('data'));
}
}
};
});
问题是它总是返回undefined,我真的不知道出了什么问题,可能出现什么问题?