jquery - How can I insert a Bootstrap modal, containing AngularJS, using .innerHTML then manually open it? -


when page loads trying do:

$(function () {     urlextract = location.hash     foundextract = urlextract.split("#/")[1];     if(foundextract == "zsexdr"){         var createmodal = "";          basicrep = document.getelementbyid('basicreports');          createmodal+='<div class="modal fade" id="#waivermodal" role="dialog">';         createmodal+='<div class="modal-dialog modal-sm">';         createmodal+='<div class="modal-content">';         createmodal+='<div class="modal-header">';         createmodal+='<button type="button" class="close" data-dismiss="modal">&times;</button>';         createmodal+='<h4 class="modal-title">{{z.name}} - downloads</h4>';         createmodal+='</div>';         createmodal+='<div class="modal-body">';         createmodal+='<span ng-repeat="z in waivermodallinks" class="{{z.id}}"><a href="{{z.link}}{{z.title}}">{{z.title}}</a></span>';         createmodal+='</div>';         createmodal+='<div class="modal-footer">';         createmodal+='</div>';         createmodal+='</div>';         createmodal+='</div>';         createmodal+='</div>';          basicrep.innerhtml+=createmodal;          $('#waivermodal').modal('show');     } }) 

the modal gets created , inserted html fine, except angularjs isn't registering, register other angular within same div id="basicreports"> using ui.bootstrap , have gotten angularjs inserted modal on different page, first time attempting insert modal dynamically , have opened programmatically. not sure if doing correctly.

my main problem is, along angular not registering, modal not opening. know modal there because if inspect element can see in html

you have use $compile angular parse html.

the modal not opening because in html have specified modal id #waivermodal instead of waivermodal. since have jquery on page can use jquery methods dom manipulation.

(function(){ var app = angular.module('avs', ['ui.bootstrap']);  app.controller('basicinformation', function($scope, $compile){     $scope.basicreports = [    {name: 'online edit', link: 'url', status:''},    {name: 'project log', link: 'url', status:''}     ];     $scope.waivermodallinks =[{       title:"title",       link:"links",       color:"color?"    }];       var urlextract = location.hash,     foundextract = urlextract.split("#/")[1];     if(foundextract == "zsexdr"){         var createmodal = "",          basicrep = $('#basicreports');          createmodal+='<div class="modal fade" id="waivermodal" role="dialog">';         createmodal+='<div class="modal-dialog modal-sm">';         createmodal+='<div class="modal-content">';         createmodal+='<div class="modal-header">';         createmodal+='<button type="button" class="close" data-dismiss="modal">&times;</button>';         createmodal+='<h4 class="modal-title">{{z.name}} - downloads</h4>';         createmodal+='</div>';         createmodal+='<div class="modal-body">';         createmodal+='<span ng-repeat="z in waivermodallinks" class="{{z.id}}"><a href="{{z.link}}{{z.title}}">{{z.title}}</a></span>';         createmodal+='</div>';         createmodal+='<div class="modal-footer">';         createmodal+='</div>';         createmodal+='</div>';         createmodal+='</div>';         createmodal+='</div>';           createmodal = $compile(createmodal)($scope);           basicrep.append(createmodal);          $('#waivermodal').modal('show');     }   });  })(); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -