JElster
asked on
Help with AngularJS Modal
Hi..
I have a controller that opens a modal window.
How can I change the templateUrl value when the modal window is opened?
$ionicModal.fromTemplateUr l('modal-d etails.htm l', {
scope: $scope,
animation: 'slide-in-up',
hardwareBackButtonClose: true
}).then(function (modal) {
$scope.modal = modal;
});
// Open window here..
$scope.openModal = function(selected){
// How can I change the templateUrl based on the selected value?
$scope.data.selected = selected;
I have a controller that opens a modal window.
How can I change the templateUrl value when the modal window is opened?
$ionicModal.fromTemplateUr
scope: $scope,
animation: 'slide-in-up',
hardwareBackButtonClose: true
}).then(function (modal) {
$scope.modal = modal;
});
// Open window here..
$scope.openModal = function(selected){
// How can I change the templateUrl based on the selected value?
$scope.data.selected = selected;
ASKER
I get
JavaScript runtime error: Unable to get property 'show' of undefined or null reference
at
self[templateurl].show();
any ideas ?
thx
JavaScript runtime error: Unable to get property 'show' of undefined or null reference
at
self[templateurl].show();
any ideas ?
thx
yeah.. i thought that might happen. it's too late. the modal is alteady initialized with the default template. if you want to test my theory you could set the default templare variable to the same one that you pass in the click function. if it works, then my theory is correct, otherwise something else is screwey and i'd have to set up an app to test it.
unfortunately it doesn't appear that ionic modal service has the capabilty of specifying a template at run time
unfortunately it doesn't appear that ionic modal service has the capabilty of specifying a template at run time
you could also try having separate instances of the ionic modal that use different templates. in the .then function set $scope.anotherModal = modal
then, do
$scope.anotherModal.show()
does that make sense? (typing on phone)
then, do
$scope.anotherModal.show()
does that make sense? (typing on phone)
ASKER
Yes.. I'll try that
thx
thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx!
that worked!
that worked!
cool :)
in the controller:
Open in new window
in the view:
Open in new window