2

I am having a Modal which opens up on a button click. In this Modal, a button uses ng-click to call a function from js file.The function doesn't get called, with no errors.

Outside the Modal the ng-click is working properly.

<div class="container-fluid" ng-app="app" ng-controller="GridCtrl">
    ....
    <div id="partial"></div>
</div>

function openModal() {                 
            jq.get('/Data/openModal?Id=' + Id, function (data) {
                jq('#partial').html(data);
                jq('#Modal').modal('show');
            });    
        }

Partial Page :-

@model Models.Data
@{       
    Layout = null;
}
<div class="modal fade bs-example-modal-lg" id="Modal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">                    
                <h4 class="modal-title" id="compModalLabel">Master</h4>
            </div>
            <div class="modal-body">    
                <div class="container">    
                        <div class="col-sm-12">
                            <button type="button" ng-click="getData('live')">Live Data</button>
                        </div>
.....
</div>

var app = angular.module('app', ['ui.grid']);

app.controller('GridCtrl', ['$scope', function ($scope) {

$scope.getData= function (status){
    .....
}

}
]);

What is the solution?

1 Answer 1

2

See here: Add DOM Elements (that are Angular directives) via jQuery .append()?

You need to have the newly added DOM elements compiled by Angular, with $compile(...)

(Although a more pure AngularJS codewould be better overall, you are mixing JQuery and NG. http://angular-ui.github.io/bootstrap/#modal)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.