我正在为我的结果做分页指令,我似乎无法克服这个问题。我有以下代码(CoffeeScript的):angularjs从作用域对象获取值
window.pagination_services = angular.module("pagination_services", [])
.directive('paginate', ->
{
restrict: 'E',
replace: true,
templateUrl: '../../assets/app/partials/services/pagination.html',
scope: true,
link: ($scope, $element, $attrs) ->
console.log $scope.results
}
)
正如你可以看到我有一个$scope.results
其中的console.log返回:
e
pagination: Object
current_page: 1
per_page: 20
total_entries: 4097
__proto__: Object
sales: Array[20]
__proto__: e
我需要能够访问分页的价值目的。例如:
$scope.results.pagination.current_page
但是,无论我尝试什么,我都会得到未定义的内容。
任何想法?
没有。控制器是该指令的父级,所以我继承它的属性。我会发布解决方案。这完全是关于异步的。我的对象是一个httppromise,这就是为什么我无法获取它。不能回答我自己的问题 – 2012-08-09 14:26:15
你可以回答你自己的问题。 – ganaraj 2012-08-09 14:51:34