如何用我在ng-include中使用的文件中的内容替换div中的内容?
<div id="fish">
<button ng-click="getPartial()">
<div ng-model="include"></div>
</div>
$scope.getPartial = function()
{
$scope.include = "partials/invoices/editcustinvoice.html";
};
如何使用editcustinvoice中的内容替换fish中的内容?
答案 0 :(得分:1)
如果您想在视图中包含内容,则需要使用ng-include指令代替ng-model,请参阅此处的示例:http://plnkr.co/edit/N4KqRaro3CiOkzKpwEUZ?p=preview 或者在这里阅读更多内容:https://docs.angularjs.org/api/ng/directive/ngInclude
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.getPartial = function()
{
$scope.include = "editcustinvoice.html";
};
});
HTML:
<body ng-controller="MainCtrl">
<button ng-click="getPartial()">get partial</button>
<div ng-include="include"></div>
</body>