简体   繁体   English

AngularJS标签示例和IE8

[英]AngularJS tabs example and IE8

I am using the tabs example on the AngularJS homepage. 我正在使用AngularJS主页上的标签示例。 I essentially just pulled that code out verbatim so it looks like this: 我基本上只是逐字地提取代码,所以它看起来像这样:

app.directive('tabs', function() {
    return {
        restrict: 'E',
        transclude: true,
        scope: {},
        controller: function($scope, $element) {
            var panes = $scope.panes = [];

            $scope.select = function(pane) {
                angular.forEach(panes, function(pane) {
                    pane.selected = false;
                });
                pane.selected = true;
            }

            this.addPane = function(pane) {
                if (panes.length == 0) $scope.select(pane);
                panes.push(pane);
            }
        },
        template:
            '<div class="tabbable">' +
                '<ul class="nav nav-tabs">' +
                '<li ng-repeat="pane in panes" ng-class="{active:pane.selected}">'+
                '<a href="" ng-click="select(pane)">{{pane.title}}</a>' +
                '</li>' +
                '</ul>' +
                '<div class="tab-content" ng-transclude></div>' +
                '</div>',
        replace: true
    };
});

app.directive('pane', function() {
        return {
            require: '^tabs',
            restrict: 'E',
            transclude: true,
            scope: { title: '@' },
            link: function(scope, element, attrs, tabsCtrl) {
                tabsCtrl.addPane(scope);
            },
            template:
                '<div class="tab-pane" ng-class="{active: selected}" ng-transclude>' +
                    '</div>',
            replace: true
        };
    })

This is working great except in IE8 the actual tabs that you click on to change the current tab are missing and I get this console error: 这很有效,除了在IE8中,您单击以更改当前选项卡的实际选项卡丢失,我收到此控制台错误:

  Error: No controller: tabs<div class=tab-pane title="Change Log" ng-class="{active: selected}" ng-transclude>

What could be going wrong in IE8? IE8可能出现什么问题?

On your directives, try replacing the restrict: 'E', to restrict: 'A' THEN change all directives to use attributes. 在您的指令上,尝试替换restrict:'E',以限制:'A'然后更改所有指令以使用属性。 Thats how I got the tabs in http://angular-ui.github.io/bootstrap/ to work in a project I'm working on that has to support IE8. 多数民众赞成我如何获得http://angular-ui.github.io/bootstrap/中的标签,以便在我正在努力支持IE8的项目中工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM