我想写一个类似angularUI的tabset directive,看了一下源码,不是很明白。
html
javascriptangular.module('angularTabset',[]) .directive('tabset',function(){ return { restrict:'EA', replace: true, transclude: true, templateUrl: 'tabset.html', scope:{ a:'=?', b:'=?', c:'=?' }, controller:function($scope){ this.a = $scope.a; this.b = $scope.b; this.c = $scope.c; }, link: function (scope, iElement, iAttrs) { } } }) .directive('tab', function () { return { restrict: 'EA', replace: true, require:'^tabset', transclude: true, templateUrl: 'tab.html', controller: function($scope){ //How to get a,b,c here? }, link: function (scope, iElement, iAttrs,ctrl) { } }; })
tab.html模板里用到了tabsetController里的a、b、c属性的值,我想在tabController里访问这三个值并实现双向绑定,该如何写?我试过在link函数里写,但貌似只执行一次,没有实现双向绑定。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号