我有一個表,我在按鈕發送NG重複數據從一個網頁到另一個頁面 - 角
<table class="addedProject" ng-show="show" width="100%" border="1" cellpadding="10" >
<tr ng-repeat="developerAdd in developer" ng-click="addDev(developerAdd);">
<td > <ion-item menu-close href="#/app/playlist" >{{ developerAdd.devname }}</ion-item> </td>
<td><ion-item menu-close href="#/app/playlist" >{{ developerAdd.emailid }}</ion-item></td>
<td><a class="button button-small button-dark" ng-click="removeDev($index)">X</a></td>
</tr>
</table>
<button class="button button-block button-positive" ng-click="addDeveloper()">Add Developer</button>
的點擊迭代TR這是第X
我想要的一切迭代tr將在新的頁面Y.
這是我的控制器。
.controller('fineAppCtrl',function($scope,$rootScope){
console.log("fineAppCtrl");
$scope.details = function(a){
$rootScope.nameObj = a.name;
$rootScope.ownerObj = a.title;
};
$scope.people = [];
$scope.submitFlag = false;
$scope.show = false;
$scope.hidetable = false;
$scope.create =function(){
if($scope.show == false){
$scope.show = true;
}
if($scope.submitFlag == false){
$scope.submitFlag = true;
}
}
$scope.addPerson = function(){
$scope.hidetable = true;
var person = {
name: $scope.name,
age: $scope.age,
title: $scope.title,
};
$scope.people.push(person);
if($scope.submitFlag == true){
$scope.submitFlag = false;
}
};
$scope.removePerson = function(index){
$scope.people.splice(index, 1);
//console.log(index);
var rows = document.getElementById('rowIteration')
.getElementsByTagName('tbody')[0]
.getElementsByTagName('tr').length;
console.log(rows);
if($scope.submitFlag == false && rows == 1){
$scope.show = false;
}
};
$scope.addDeveloper = function(){
var developerAdd = {
devname : $scope.devname,
releasedate : $scope.releasedate,
emailid: $scope.emailid,
phonenumber : $scope.phonenumber,
};
$scope.developer.push(developerAdd);
$scope.removeDev = function(index){
$scope.developer.splice(index, 1);
};
};
})
我在角度很新,所以我不好,如果代碼是不按標準
-ve? – supersaiyan
最簡單的方法是將數據存儲在$ rootScope中,它在所有控制器之間共享,它不是最好的方式,但它可以完成這項工作。 –
如何將所有迭代的數據存儲到rootcope?爲前。我添加10個開發人員,那麼我怎麼可以添加10個開發人員到頁面Y @ AlexG – supersaiyan