javascript - angular-ui-bootstrap:如何在垂直和水平选项卡集 View 之间切换

标签 javascript css angularjs twitter-bootstrap angular-ui-bootstrap

目前我使用通过 Controller $scope.isNotMobileView 传递给模板的 isNotMobileView:

<uib-tabset active="0" vertical="isNotMobileView">
  <uib-tab index="0" heading="foo">
    ...
  </uib-tab>
  ...
</uib-tabset>

但是,当我切换方向/切换屏幕尺寸时,这不会动态更改呈现的 uib-tabset。我怎么做? (我正在寻找与 Twitter bootstrap 的 hidden-xs 等元素类似的行为,当我改变屏幕尺寸时隐藏和改变元素)我不想复制 uib-tabset 因为它不会那么可维护。

最佳答案

来自文档

vertical $ (Default: false) - Whether tabs appear vertically stacked.

$ 符号表示属性期望和表达式,但它没有应用观察器

$ - This setting expects an angular expression instead of a literal string. If the expression support a boolean / integer, you can pass it directly.

这意味着您提供一个表达式,该表达式将解析为 true 或 false,并将您的选项卡集初始化为该设置,但您以后不能更改它。

I do not want to duplicate the uib-tabset as it wouldn't be that maintainable.

除非你想请求一个功能或自己实现它,否则你必须制作一个副本并使用 ngIf 或其他东西来切换它。 您可以根据索引值在选项卡集之外显示和隐藏指令,使它们更易于维护(小),active 属性对其进行监视

active (Default: Index of first tab) - Active index of tab. Setting this to an existing tab index will make that tab active.

关于javascript - angular-ui-bootstrap:如何在垂直和水平选项卡集 View 之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46058655/

相关文章:

javascript - 为什么私有(private)函数无法访问Javascript对象中的成员变量?

javascript - Jquery 在 .load() 之前显示图像

javascript - 如何在 vue 3 和 typescript 中正确键入 vuex 模块

html - 使用 Bootstrap 覆盖两个图像

javascript - 如何在 Angular 中构建完整的动态模板?

javascript - Angular : Get ng-model by ng-attr-id?

html - 当隐藏第二个 div 的溢出时,div 的一部分在另一个 div 上

html - 按钮在 Angular2 表单内重新加载(也是一种 css)

javascript - 显示一个值或另一个值,具体取决于它是否存在

javascript - Angularjs:对象更改后 ng-model 不刷新