Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49359

Two modal two controller

$
0
0

@darioielardi wrote:

hi guys,
i have an app.js with two controller and a modal for each one:

angular.module('starter', ['ionic'])

$ionicModal.fromTemplateUrl('templates/modal1.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});

$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};

});

.controller('ctrl2', function($scope, $ionicModal) {

$ionicModal.fromTemplateUrl('templates/modal2.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
})

$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};

});

then in the index.html:

<div ng-controller="ctrl1">

<button ng-click="openModal()">show modal 1</button>

</div>
<br>

<div ng-controller="ctrl2">

 <button ng-click="openModal()">show modal 2</button>

</div>

why it doesn't work?

please help me, sorry I'm a neophyte

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49359

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>