I have an Html variable embedded within some Html that I retrieve from the database into an AngularJS $scope object. I then render this in a MVC/razor view using the ng-bind-html directive. A simple example follows:
myView.cshtml
<html>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="pageSizeHtml"></p>
</div>
</body>
</html>
myCtrl.js
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope) {
$scope.pageSizeHtml = '<div>Your page size is: @OurSystem.Configuration.PageSize</div>'
});
When I run this the rendered page looks like this:
Your page size is: @OurSystem.Configuration.PageSize
But I want it to interpret the value of the Razor variable and look like this:
Your default page size is: A4
Really stuck on this so any help would be appreciated!
ng-initand pass it in from the view instead. I have a working example I'll stick into an answer.