这不是一个扭曲的问题,但不知怎的让我困惑。
HTML-A
此视图呈现屏幕名称(例如:Home)以及与之相关的所有关联导航。
<div ng-repeat="content in Data.ContentDataList">
<div>{{content.Name}</div>
<div>
<li ng-repeat="nav in content.NavigationList" >{{nav.Text}}</li>
</div>
</div>
HTML-B
在同一视图中,这将呈现所有可用导航的列表
<dl>
<dd ng-repeat="item in selectedItems">
<input type="checkbox" ng-model="item.isSelected" ng-click="addNav(item.contentData.Name )" />{{ item.contentData.Name }}
</dd>
</dl>
控制器
app.controller('NavController', ['$scope','Service','$routeParams', function ($scope, Service, $routeParams) {
$scope.items = [];
$scope.Data = [];
$scope.selectedItems = [];
$scope.addNav = function() {
????? Fire an event to add selected navigation from HTML-B to HTML-A ??????
};
Service.getData(xyz).then(function (results) {
$scope.Data = results.data;
$scope.items = $scope.Data.ContentDataList;
for(var i=0; i<$scope.items.length; i++) {
var mycl = {'contentData' : $scope.items[i],
'isSelected' : false };
$scope.selectedItems.push(mycl);
};
});
答案 0 :(得分:0)
这是addNav函数;
$scope.addNav = function(cbName) {
content.NavigationList.push({text:cbName});
};