use*_*604 14 angular-ui-bootstrap
我正在使用来自http://angular-ui.github.com/bootstrap/的accordion指令,我需要在标题部分有两个按钮.
我是AngularJS的新手,请帮助我实现这一目标.
bek*_*kos 33
看到一个工作的plunker.
您只需要在控制器中添加和删除功能
$scope.addGroup = function(idx, group, e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
var newGroup = angular.copy(group);
newGroup.no = $scope.groups.length + 1;
$scope.groups.splice(idx + 1, 0, newGroup);
};
$scope.removeGroup = function(idx, e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
$scope.groups.splice(idx, 1);
};
Run Code Online (Sandbox Code Playgroud)
和ng-repeat你的HTML:
<accordion close-others="oneAtATime">
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
<accordion-heading>
{{ group.title }} ({{group.no}})
<button class="btn btn-small" ng-click="addGroup($index, group, $event)">+</button>
<button class="btn btn-small" ng-click="removeGroup($index, $event)" ng-show="$index">-</button>
</accordion-heading>
{{group.content}}
</accordion-group>
</accordion>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15128 次 |
| 最近记录: |