angular-ui:无法将Tab设置为活动状态

时间:2013-08-05 15:17:41

标签: angularjs angular-ui

我得到了角度误差:

Error: l is not a function
.compile/</<@http://localhost/investui/app/vendor/uibootstrap/ui-bootstrap-tpls-0.4.0.min.js:1
Scope.prototype.$digest@http://localhost/investui/app/lib/angular.js:8811
Scope.prototype.$apply@http://localhost/investui/app/lib/angular.js:9012
done@http://localhost/investui/app/lib/angular.js:10265
completeRequest@http://localhost/investui/app/lib/angular.js:10449
createHttpBackend/</xhr.onreadystatechange@http://localhost/investui/app/lib/angular.js:10407

http://localhost/investui/app/lib/angular.js
Line 6349

我正在尝试动态设置标签处于活动状态。使用angular-ui中引导程序的tabset。

控制器:

$scope.sectorIndustryActive = 0;
$scope.isSectorIndustryActive = function(sectorIndustry) {
    return sectorIndustry.id == $scope.sectorIndustryActive;
};

$scope.sectorIndustries = sectorsFctr.get();

模板:

    <tabset>
        <tab ng-repeat="sectorIndustry in sectorIndustries" 
             heading="{{ sectorIndustry.name }}" 
             active="isSectorIndustryActive(sectorIndustry)">

1 个答案:

答案 0 :(得分:0)

根据关于Github的讨论:

https://github.com/angular-ui/bootstrap/issues/611

active只能指向范围内的变量,它不能评估函数调用。

因此,您需要为每个sectorIndustries设置范围(或数组)的变量,并将活动属性指向该值。