AngularJS-控制器指令中的访问范围
我正在使用Angular-UI.github.io/bootstrap的Angular UI分页/ 在这里,我需要访问一个有用的数字:totalItemsAngularJS-控制器指令中的访问范围,angularjs,twitter-bootstrap,pagination,scope,directive,Angularjs,Twitter Bootstrap,Pagination,Scope,Directive,我正在使用Angular-UI.github.io/bootstrap的Angular UI分页/ 在这里,我需要访问一个有用的数字:totalItems .directive('pagination', ['$parse', 'paginationConfig', function($parse, config) { return { restrict: 'EA', scope: { page: '=',
.directive('pagination', ['$parse', 'paginationConfig', function($parse, config) {
return {
restrict: 'EA',
scope: {
page: '=',
totalItems: '=',
onSelectPage:' &'
},
controller: 'PaginationController',
templateUrl: 'template/pagination/pagination.html',
replace: true,
link: function(scope, element, attrs, paginationCtrl) {
我如何从我的控制器访问它?我尝试了$scope.totalItems
,但什么也没发生。没有错误
如果我查看指令中的totalItems,它将返回正确的值,但正如我所说的,我需要从控制器访问它。也可能在HTML本身中
谢谢你能展示一下标记吗。基本上就是这样,但我正在本地链接到UI分页指令和控制器。Plunker在胡闹,我现在无法保存。我注意到上面的指令实际上有自己的控制器。这是一个不同的控制器,我已经做了。也许这就是问题所在?您是将控制器注入此指令还是在外部作用域上有控制器?除非引导程序正在执行某些操作(在声明模块时必须包含ui.bootstrap),否则我不会显式执行。