Angularjs 动态更改uib选项卡集属性中的值
在我的项目中,我使用Angularjs 动态更改uib选项卡集属性中的值,angularjs,twitter-bootstrap,angular-bootstrap,Angularjs,Twitter Bootstrap,Angular Bootstrap,在我的项目中,我使用ui.bootstrap.tabs。在md和lg屏幕上,选项卡应垂直堆叠显示,但在sm和xs屏幕上,我希望看到它们水平显示。我只需要在垂直属性中设置值true或false。当屏幕大小更改时,我对md或lg大小进行匹配,并设置属性vertical\u tab\u appearance=true,与sm和lg大小相同,属性具有false值,但uib tabset指令不知道该属性的值已更改 <div class="col-md-2 small hidden-print"&g
ui.bootstrap.tabs
。在md
和lg
屏幕上,选项卡应垂直堆叠显示,但在sm
和xs
屏幕上,我希望看到它们水平显示。我只需要在垂直属性中设置值true或false。当屏幕大小更改时,我对md
或lg
大小进行匹配,并设置属性vertical\u tab\u appearance=true
,与sm
和lg
大小相同,属性具有false
值,但uib tabset
指令不知道该属性的值已更改
<div class="col-md-2 small hidden-print">
<div ng-model="value">
<uib-tabset vertical="vertical_tab_appearance" type="pills">
<uib-tab></uib-tab>
</uib-tabset>
</div>
</div>
在这种情况下,我可以在这里做些什么,或者我应该使用
ng吗?如果其他人也会面临同样的问题,这里有一个解决方案。我决定在模块配置中使用uibTabsetDirective
decorator,并将watcher添加到链接函数的垂直属性中
.config(function ($provide) {
$provide.decorator('uibTabsetDirective', function($delegate) {
var directive, link, scope;
directive = $delegate[0];
link = directive.link;
scope = directive.scope;
scope['vertical'] = '=';
directive.compile = function() {
return function Link(scope, element, attrs, ctrls) {
scope.$watch(attrs.vertical, function() {
console.log(scope.vertical);
});
return link.apply(this, arguments);
};
};
return $delegate;
});
});
如果其他人也会面临同样的问题,这里有一个解决方案。我决定在模块配置中使用uibTabsetDirective
decorator,并将watcher添加到链接函数的垂直属性中
.config(function ($provide) {
$provide.decorator('uibTabsetDirective', function($delegate) {
var directive, link, scope;
directive = $delegate[0];
link = directive.link;
scope = directive.scope;
scope['vertical'] = '=';
directive.compile = function() {
return function Link(scope, element, attrs, ctrls) {
scope.$watch(attrs.vertical, function() {
console.log(scope.vertical);
});
return link.apply(this, arguments);
};
};
return $delegate;
});
});