Reputation: 1
I have an ion-list and I create each ion-item from a select statment. The ion-item tag has a ng-click event that call a modal window but it never call the show() method from controller. For test I put a static ion-item without DOM modification and it works well.
This is the code:
Modal controller
function uib_w_27_modal_controller($scope, $ionicModal) {
$scope.modal = $ionicModal.fromTemplate($(".uib_w_27").html(), {
scope: $scope,
animation: 'slide-in-up'
});
$scope.show = function() {
$scope.modal.show();
};
$scope.close = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
};
Dynamic element
function getFarmaciasSelect(tx, result){
var elem = '';
for (var i = 0; i < result.rows.length; i++) {
var row = result.rows.item(i);
elem += '<ion-item class="item widget uib_w_24 d-margins item-avatar item-icon-right" data-uib="ionic/list_item_avatar" data-ver="0">' +
'<img src="images/Strabburg.jpg">' +
'<h2>' + row['nombre'] + '</h2>' +
'<p>' + row['calle'] + ' ' + row['altura'] + '</p>' +
'<a href="tel:' + row['fijo'] + '"style="text-decoration:none;color:#4CAF50" >' + row['fijo'] + '</a>' +
'<i class="icon ion-plus-circled ion" uib-icon-position="right" ng-controller="uib_w_27_modal_controller" ng-click="show()" data-email="[email protected]"></i>' +
'</ion-item>';
console.log(elem);
}
$('#farmacias-list').html(elem);
}
Thanks for help!
Upvotes: 0
Views: 428
Reputation: 1705
If you really need to keep generating in your code then you need compile your content before add to '#farmacias-list'
$('#farmacias-list').html($compile(elem)($scope));
but even it work, I will recommend you to use collection-repeat to generate content in angular context.
Upvotes: 1