1

I am loading a partial view with input fields and a submit button.

The partial view is loaded from my ASP.NET MVC controller, but somehow the button is not invoked by my ng-click.


Example

index.controller.js

$scope.addClient = function() {
$http.get('/FileMaintenance/AddClient')
    .then(function (response) {

            var divTemplate = response.data;
            divTemplate = $sce.trustAsHtml(divTemplate);
            $scope.chosen_view = divTemplate;
            var element = angular.element(document.getElementById('btnAddCompany'));
            element.append(divTemplate);
            $compile(element)($scope);
    },
        function(error) {
            alert('An error occured in retrieving view. ' + error.message);
        });

};

index.html

<div id="file_maintenance_view_area">
    <div ng-bind-html="chosen_view">

    </div>
</div>

Loading the partial view from ASP.NET mvc

<div>
    <a href="javascript:void(0);" ng-click="addClient()">Add Client</a>
</div>
Trent
  • 4,208
  • 5
  • 24
  • 46
stack questions
  • 862
  • 2
  • 15
  • 29

0 Answers0