4

I had a situation where, When I click button the controller method is called. The $http.get will give me a URL as a response. When I hit that url I get bootstrap modal(all the modal html) as response. I want to show that modal response into the bootstrap modal that I have.

How can I do that ?

The button:

<button type="button" class="btn btn-primary" data-target="#pwdConfirm" ng-click="doMethod('ResetPassword',@Model.Id)"><span class="col-sm-12 fa fa-refresh"> Reset Password</span></button>

The controller code:

$scope.doMethod = function (method, Id) {
    var userId = Id;
    var url =  "http://" + $window.location.host+ "/User/" +method+"?id=" + userId;
    //var url = $window.location.host + "/User/" + method + "?id=" + userId;
    $http({
        method: 'GET',
        url: url            
    }).success(function (response) {            
        $scope.successresponse = response;
        console.log(response);

    }).error(function (response) {
        alert(response);
    });

Controller response from console.log statement:

<div class="modal-dialog">
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Password Reset</h4>
    </div>
    <div class="modal-body">
        <div class="col-md-12">
            <img src="/Content/images/greenCheck.png" title="logo" class="imgLogo" />
        </div>
        <div class="col-md-12">
            <p>Password Reset to Default</p> 
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4"></div>
        <div class="col-md-8">
            Password :  bforce
        </div>
    </div>
    <div class="modal-footer">
        <div class="col-md-6 row">
            <a class="page-header fa fa-edit  btn btn-warning" href="/User/Index" style="color:white">Activate later</a>
        </div>
    </div>
</div>

Now I want this response to be shown as a boostrap modal in another page. How can I do that ?

Sreelatha
  • 41
  • 2

1 Answers1

0
$scope.doMethod = function (method, Id) {
    var userId = Id;
    var url =  "http://" + $window.location.host+ "/User/" +method+"?id=" +    userId;
    //var url = $window.location.host + "/User/" + method + "?id=" + userId;
 $http({
    method: 'GET',
    url: url            
 }).success(function (response) {            
    $scope.successresponse = response;
    console.log(response);
    var showBadRoleModelInstance = $modal.open({
        template: "<div ng-bind-html='htmlContent'></div>",
        backdrop: true,
        windowClass: 'modal',
        controller: modalController,
        resolve: {
            htmlContent: function () {
                return response;
            }
        }
    });
}).error(function (response) {
    alert(response);
});



function modalController(htmlContent){
    $scope.htmlContent = htmlContent;
}
sirrocco
  • 7,975
  • 4
  • 59
  • 81