gpt4 book ai didi

javascript - 我的 li 范围没有在 Angular js 中删除为什么?

转载 作者:行者123 更新时间:2023-11-28 15:35:52 24 4
gpt4 key购买 nike

嗨,请帮助我,我是 Angular JS 的新手

我只是创建一个函数。我重复一下内容。我创建一个函数,添加下一个选项卡部分并删除此部分。我为另一个选项卡创建相同的功能,添加上一个选项卡部分并删除此部分。

但我只知道数据复制此功能不删除数据也不显示。

请帮助我

我的代码是这样

HTML 代码为

<body ng-app="taskPanel">
<div class="" ng-controller="TasksController">
<tabset panel-tabs="true" panel-class="panel-inverse">
<tab>
<tab>
<tab-heading> <span class="hidden-xs">ACTIVE</span> <span class="badge badge-primary">{{tasksComplete.length}}</span></tab-heading>
<div class="tasklist">
<ol class="panel-tasks">
<li ng-repeat="item in tasksComplete">
<a href="#" class="preview-question">
<i class="fa fa-eye">eye</i>
</a>
<label>
<span class="task-description">{{item.title}}</span>
<span class="label label-{{item.color || 'primary'}}" ng-show="item.label">{{item.label}}</span>
<div class="more-icn">
<div class="pull-left">
<button class="active-check" ng-click="pushActive(this, item)">Push to InActive Tab</button>
</div>

</div>
</label>
</li>
</ol>
</div>
</tab>
<tab>
<tab-heading> <span class="hidden-xs">InACTIVE</span> <span class="badge badge-primary">{{tasksComplete.length}}</span></tab-heading>
<div class="tasklist">
<ol class="panel-tasks">
<li ng-repeat="item in tasksInComplete">
<a href="#" class="preview-question">
<i class="fa fa-eye"></i>
</a>
<label>
<span class="task-description">{{item.title}}</span>
<span class="label label-{{item.color || 'primary'}}" ng-show="item.label">{{item.label}}</span>
<div class="more-icn">
<div class="pull-left">
<button class="active-check" ng-click="pushInActive(this, item)">Push To Active Tab</button>
</div>

</div>
</label>
</li>
</ol>
</div>
</tab>

</tabset>

</div>
</body>

Angular Js 代码是

//代码放在这里

var appan = angular.module('taskPanel', []);
appan.controller('TasksController', ['$scope', function($scope){
$scope.tasksComplete = [
{ title: "I m first" },
{ title: "I m Second" },
{ title: "I m thrid" }
];


$scope.tasksInComplete = [
{title: "i m incompletred 1"},
{title: "i m incompletred 2"},
{title: "i m incompletred 3"}
];


$scope.remove = function(scope){
scope.remove();
};


$scope.pushActive = function(scope, item){
$scope.tasksInComplete.push(item);
scope.remove();
};

$scope.pushInActive = function(scope, item){
$scope.tasksComplete.push(item);
scope.remove();
};

}]);

Live Demo

最佳答案

你可以使用这样的方法:

Controller :

 $scope.tasksComplete = [
{ title: "I m first"},
{ title: "I m Second"},
{ title: "I m thrid"}
];

$scope.pushActive = function(item) {
$scope.tasksComplete.splice(item,1);
};

查看

ng-click="pushActive($index)"

关于javascript - 我的 li 范围没有在 Angular js 中删除为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25658638/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com