我有一个观点,其包含一个链接调用PartialView。
<div data-ng-controller="MainController">
<a href="#" data-ng-click=callPartialView()">
Click here to see the details.
</a>
</div>
<script>
app.controller('MainController', ['$scope', 'HttpService',
function($scope, HttpService) {
$scope.callPartialView = function() {
HttpService.getModal('/Controller/ShowModalMethod', {});
};
}]);
</script>
我HttpService的服务具有调用来自控制器的作用,以显示它返回一个PartialView功能。
getModal = function(url, params) {
$http.get(url, params).then(function(result) {
$('.modal').html(result);
});
}
所述PartialView是完全示出。 当我尝试将控制器添加到PartialView内容将出现问题。
<div class="wrapper" data-ng-controller="PartialViewController">
<span data-ng-bind="description"></span>
</div>
<script>
alert('This alert is shown.');
app.controller('PartialViewController', ['$scope', 'HttpService',
function($scope, HttpService) {
$scope.description = "That's the content must have to appear in that bind above, but it isn't working properly.";
}]);
</script>
控制器与预期不工作。 无我把控制器内出现在上述股利。 发生了什么? 谢谢你们!