내가 달성하려는 것은 내 그리드의 항목을 두 번 클릭하고 항목을 탐색 할 때 내 이동 경로가 업데이트된다는 것입니다. 하지만 이동 경로를 다시 클릭하면 이동 경로 이전 값이 제거되지만 두 번 클릭하여 다시 내부로 이동하면 이전 제거 값도 표시됩니다. 더 잘 이해할 수 있도록 코드와 이미지를 첨부하고 있습니다.
<div id="breadCrumb"><div ng-click="breadCrumbFilter('^/xyz/$')" style="float:left;">xyz</div>
<div ng-repeat="bCrumb in bCrumbs" id="{{bCrumb.name}}" style="float:left;
" ng-click="breadCrumbFilter(bCrumb)">{{ bCrumb.name }}</div></div>
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.filterOptions = {
filterText: '^/xyz/$'
};
$scope.breadCrumbFilter = function(bCrumb) {
var filterText = bCrumb.path;
if(filterText == null){
filterText = bCrumb;
}
var active = $scope.filterOptions.filterText;
if ($scope.filterOptions.filterText === filterText) {
$scope.filterOptions.filterText = filterText;
}
else if ($scope.filterOptions.filterText !== '' ) {
$scope.filterOptions.filterText = filterText;
}
$scope.resetBreadcrumbs(filterText,active);
};
$scope.resetBreadcrumbs = function(fText,rActive){
var reset = fText;
var activeBreadcrumbs = rActive;
activeBreadcrumbs = activeBreadcrumbs.substring(reset.length -1, activeBreadcrumbs.lastIndexOf("/"));
var myEl = angular.element(document.getElementById('/ '+activeBreadcrumbs));
myEl.remove();
};
$scope.filterFpath = function(row) {
var fileName = row.entity.name;
var folderPath = row.entity.Full_Path;
var newPath = folderPath+fileName+'/';
var filterText = '^'+newPath+'$';
if ($scope.filterOptions.filterText ==='^'+folderPath+'$') {
$scope.filterOptions.filterText = filterText;
}
else if ($scope.filterOptions.filterText === filterText) {
$scope.filterOptions.filterText = '';
}
$scope.addname('/ '+fileName,filterText);
};
$scope.bCrumbs = [] ;
$scope.addname=function(name,path)
{
obj={};
obj['name'] = name;
obj['path'] = path;
$scope.bCrumbs.push(obj);
};
var rowTempl = '<div ng-dblClick="filterFpath(row)" ng-style="{ \'cursor\': row.cursor }" ng-repeat="col in renderedColumns" '+'ng-class="col.colIndex()" class="ngCell{{col.cellClass}}"><div ng-cell></div></div>';
$scope.myData = [{name: "Moroni", Full_Path: "/xyz/"},
{name: "Tiancum", Full_Path: "/xyz/Moroni/"},
{name: "Jacob", Full_Path: "/xyz/"},
{name: "Nephi", Full_Path: "/xyz/Moroni/Tiancum/"},
{name: "Nephiss", Full_Path: "/xyz/"}];
$scope.gridOptions = {
data: 'myData',
filterOptions: $scope.filterOptions,
rowTemplate: rowTempl,
};
});
지금 무슨 일이 일어나고 있는지 : 기본적으로 표시되는 이동 경로 'xyz'에 데이터가로드 될 때 첫 번째 이미지
What is the issue i am not able to figure it out.
By seeing your code i found out that you are removing dom element but you are not deleting it from array so try finding index of the desired remove file and then use 'slice' in that.
Try something like this:
<div id="breadCrumb"><div ng-click="breadCrumbFilter('^/xyz/$')" style="float:left;">xyz</div>
<div ng-repeat="bCrumb in bCrumbs" id="{{bCrumb.name}}" style="float:left;
" ng-click="breadCrumbFilter(bCrumb,$index)">{{ bCrumb.name }}</div></div>
$scope.breadCrumbFilter = function(bCrumbs,$index) {
$scope.bCrumbs.splice($index+1);
var d = $scope.bCrumbs.length -1;
path = bCrumbs[d].path;
var filterText = path;
if(filterText == null){
filterText = bCrumb;
}
var active = $scope.filterOptions.filterText;
if ($scope.filterOptions.filterText === filterText) {
$scope.filterOptions.filterText = filterText;
}
else if ($scope.filterOptions.filterText !== '' ) {
$scope.filterOptions.filterText = filterText;
}
};
try this out.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다