In the below code, I am having a template and based on the IsEdit flag the corresponding view will be rendered. From here, Is there a way to get the angular parsed HTML which is only visible to the view.
e.g.
If IsEdit = false, then I want the rendered HTML as
<div>
View Mode
</div>
or even
<div ng-show="!IsEdit">
View Mode
</div>
var app = angular.module("myApp", []);
app.controller("myCtrl", function ($scope) {
$scope.IsEdit = false;
$scope.GetTemplate = function () {
console.log($("#Template").html());
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div id="Template" ng-app="myApp" ng-controller="myCtrl">
<div ng-show="IsEdit">
Edit Mode
</div>
<div ng-show="!IsEdit">
View Mode
</div>
<button ng-click="GetTemplate()">Get HTML</button>
</div>