【发布时间】:2016-05-20 05:50:52
【问题描述】:
我正在做一个如下所示的角度页面,数据表部分属于ng-view(使用ngRoute),上面的导航栏属于index.html,它是父级。同样在子视图中,底部有一个导航栏。现在我想把这两个导航栏放在一起(将子导航栏移到 ng-view 之外)。我试图将子导航栏放入 index.html,然后 ng-controller='childController' ,它没有显示任何内容。
=======
如果我在数组中制作一些固定数据,那么它可以显示出来。但是在子控制器中动态生成的数据不起作用
这是我的部分代码
我把子导航栏放在index.html中,然后添加子控制器:
<ul ng-controller="imagesController" >
<li ng-repeat="y in subNav">{{y.name}}</li>
</ul>
<div><ng-view></ng-view></div>
在子控制器中,我将数据推送到 ng-repeat 使用的“subNav”数组
/*clicking folder in datatable*/
$scope.getInfo = function(index) {
if($scope.applicationimages[index].type == 'folder') {
$http({
method: 'GET',
url: $scope.url + '/' + $scope.applicationimages[index].name
}).then(function(response) {
$scope.subNav.push({name: $scope.applicationimages[index].name, suburl: $scope.url});
$scope.url += '/' + $scope.applicationimages[index].name;
$scope.applicationimages = response.data.payload.list;
}, function(response) {
console.log('http error');
})
}
}
/*child navigation bar*/
$scope.subNav = [];
$scope.getCurrentNav = function(index) {
$http({
method: 'GET',
url: $scope.subNav[index].suburl + '/' + $scope.subNav[index].name
}).then(function(response) {
$scope.subNav.splice(index+1);
$scope.applicationimages = response.data.payload.list;
$scope.url = $scope.subNav[index].suburl + '/' + $scope.subNav[index].name;
}, function(response) {
console.log('http error');
})
}
【问题讨论】:
标签: javascript angularjs