Html 在下拉列表中使用时,元素列表在angular js中被覆盖
我想显示像图中那样的层次结构。我能够创建这个层次结构,我想在下拉列表中显示第二级元素。但是,在执行此操作时,层次结构值会被下拉值覆盖,因此我无法显示层次结构的第三级 这是我的下拉html页面: 商业领域 嗯 这是我的控制器:Html 在下拉列表中使用时,元素列表在angular js中被覆盖,html,angularjs,Html,Angularjs,我想显示像图中那样的层次结构。我能够创建这个层次结构,我想在下拉列表中显示第二级元素。但是,在执行此操作时,层次结构值会被下拉值覆盖,因此我无法显示层次结构的第三级 这是我的下拉html页面: 商业领域 嗯 这是我的控制器: controller('domainController', ['$scope', '$state', 'DomainNameService', function($scope, $state, DomainNameService) { $scope.busd
controller('domainController', ['$scope', '$state', 'DomainNameService', function($scope, $state, DomainNameService) {
$scope.busdomain = DomainNameService.getBusDomainName();
/*For populating the domain values Which I am fetching from service
Attached the json image*/
var domainList=DomainNameService.getBusDomainName();
if(domainList!=null){
domainList[0].childNode.sort();
for (var i = 0; i < domainList[0].childNode.length; i++) {
if (domainList[0].childNode[i].name!=null) {
var name=domainList[0].childNode[i].name;
domainList[0].childNode.splice(i,1,name);//for replacing the object with name as I have to show name in dropdown list
$scope.busdomainname=domainList[0].childNode;//got the list of name but after this my service list also get overrides
$scope.busdomainname.sort();
break;
}
else
{
$scope.busdomainname=$scope.busdomain[0].childNode;//Added for getting business domain list
$scope.busdomainname.sort();
}
}
}
$scope.addSubDomainTree = function(val){
var varType = "busSubDomain";
var domain=[];
var busDomain=$scope.bussubdomain;
var parent = DomainNameService.getDomainName()[0];
//Done some code here to get the hierarchy
DomainNameService.setBusDomain($scope.statements);
$scope.domain.domainName = DomainNameService.getBusDomainName[0];
$state.go('BusDomainTree', null, { reload: true });//fix for refresh issue.
}
}
}
有人能建议如何解决这个问题吗?找到了解决方案。我使用了var-domainList=angular.copy($scope.busdomain),而不是var-domainList=DomainNameService.getBusDomainName();在controller.js中–最好创建一个干净的plunkr或fiddle,这会给我们带来更好的想法。找到了解决方案。我使用了var-domainList=angular.copy($scope.busdomain),而不是var-domainList=DomainNameService.getBusDomainName();在controller.js中
setChildBD: function(varType,childBD,value,val){
if(varType == "busSubDomain"){
this.error=undefined;
if(childSubDomainName.indexOf(childBD)==-1){
childSubDomainName.push(childBD);
var i= childDomainName.indexOf(val);
//Done this for replacing the object name with an array which contains the child.attached the image for its value
childDomainName.splice(i,1,value.childNode[0]);
}
},
getBusDomainName: function(){
return this.busDomainValue;//here the busDomainValue gets overrided with the controller list value
},