jQuery UI Tab 与 Angular JS 绑定(bind)

标签 jquery angularjs jquery-ui jquery-ui-tabs

我尝试了这个问题的答案。 Jquery UI tab not working in AngularJS

但是我用我的应用程序尝试过,div 会重复出现。

这是我的代码,

HTML

<html data-ng-app="recipes">
   <!--- links and sources -->
   <body data-ng-controller="recipe-controller">
      <div id="tabs" ng-tabs>
         <ul>
            <li ng-repeat="page in jPages">
                <a class="pageName" href="#{{page.id}}">{{page.name}}</a>
            </li>
         </ul>
         <div id="{{page.id}}" ng-repeat="page in jPages">
            <p>{{page.id}}</p>
         </div>
      </div>
   </body>
</html>

JS

var app = angular.module('recipes', ['ui.bootstrap', 'ngSanitize', 'timer', 'emoji', 'ngGrid', 'ngCsv', 'xeditable'])

app.directive('ngTabs', function() {
   return function(scope, elm) {
      setTimeout(function() {
        elm.tabs();
      },0);
   };
});

app.controller('recipe-controller', function ($scope, $http, $filter, $modal, $timeout, recipesFactory, config, ShoppingListsFactory, $rootScope) {
var pageArray = [
    {
    "id": "tab1",
    "name": "tab1"},
    {
    "id": "tab2",
    "name": "tab2"},
    {
    "id": "tab3",
    "name": "tab3"},
    {
    "id": "tab4",
    "name": "tab4"},
    {
    "id": "tab5",
    "name": "tab5"},
    {
    "id": "tab6",
    "name": "tab6"},
    {
    "id": "tab7",
    "name": "tab7"},
    {
    "id": "tab8",
    "name": "tab8"}
    ];
    $scope.jPages = pageArray;

});

这是我实际输出的屏幕截图。

enter image description here

我正在使用 jQuery UI 选项卡,因为我需要它与 IE8 一起使用,Angular Bootstrap 中的选项卡集在 IE8 中无法正常工作。

最佳答案

尝试添加这段代码,看看是否有效。

function recipes($scope) {
   $scope.pages = pageArray;
}

关于jQuery UI Tab 与 Angular JS 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28337752/

相关文章:

javascript - 自定义特定 jquery-ui 对话框的样式不是所有对话框?

javascript - 如何使带有不可点击类的 <a> 标签?

c# - 如何在 .net 中获取客户端 IP 地址?

jQuery Mobile 滑动事件

angularjs - 如何在 Angular 1 中使用 npm 安装模块

javascript - 使用 AngularJS 连接到 MySQL 数据库

一个 html 页面上的 jQuery 简单多模态

javascript - Ruby on Rails 使用 OR 查找

jquery - Twitter Bootstrap CSS + jQuery

javascript - 如何在 Jquery Ui Datepicker 中禁用除周三和周日日期之外的所有日期