I'm super new to angular, and I've been told of it's greatness, but also of it's annoyingly high learning curve. I've been repeatedly smashing my head against the wall now for the better half of 3 hours trying to figure something out.
I couldn't find any documentation on it either. I either don't know what to search, or it isn't possible anymore or something.
function modalCtrl($scope, $modal) {
$scope.openManageMainCd = function() {
var modalInstance = $modal.open({
templateUrl: 'views/modalManageMainCd.html',
controller: ModalInstanceCtrl
});
};
$scope.openLadders = function(e) {
alert(e);
var modalInstance = $modal.open({
templateUrl: 'views/ladderModal.html',
controller: LadderInstanceCtrl
});
};
};
function LadderInstanceCtrl($scope) {
$scope.ladder = GetLadderData(_facilityData.holdings);
};
function GetLadderData(holdings){
var holdingData = [];
angular.forEach(holdings, function(value, key) {
if (value.type == 'Ladder') {
angular.forEach(value.cds, function(value, key) {
var obj = { type: value.type, name: value.name, amount: value.amount, rate: value.rate, maturityDate: value.maturityDate }
holdingData.push(obj);
});
}
});
return holdingData;
};
This big jumbled mess is what I have created with my time. When a row on my table is clicked, it calls the openLadders function. Right now, I've tried sending it everything under the sun, and none of it has helped so far. I want to send it basically the row. There is an ID I need from the row, I just want that ID. I've tried....
ng-click="openLadders(row) == function says row is undefined
ng-click="openLadders($event) == I have no idea what i am looking at
ng-click="openLadders($index) == Doesn't help me
and many more. Angular's website doesn't really go into detail with what I need to know so I was unable to find help there. I have went through two tutorials on Angular on websites which make me believe that it is possible.
Can anyone offer any shred of help here? I'm so lost.
The table is build like this:
<tr ng-repeat="holding in holdings" ng-if="holding.type == 'Ladder'" class="" ng-controller="modalCtrl" ng-click="openLadders()">
<td><i class="icon-plus" ></i> {{holding.type}}</td>
<td contenteditable="true">{{holding.name}}</td>
<td>{{holding.maturityDate}}</td>
<td>{{holding.amount | currency:"$"}}</td>
<td>{{holding.rate | percentage:2}}</td>
</tr>
There seems to be an obvious follow up question that I will have, which will be sending that information once I get it from the function openLadders to the actual LadderInstanceCtrl(). So help on either topic would be severely appreciated.
Thank you so much.
$scopeitem it is coming from and what is available.holding.idthat you want passed toopenLadders?LadderInstanceCtrl, I'd suggest reading a bit about Services and Controllers. In Angular's model,openLadderswould be in the controller, which would have a dependency (injection) to aLadderInstanceService(replacing yourLadderInstanceCtrl). This is more an issue of understanding Angular's adequate application architecture than any specific problem you are facing. Best luck with Angular, which is indeed very good.