Angular component’s template points to an MVC view, yet its embedded JavaScript doesn’t execute properly. See the revised Angular component and MVC view examples below:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: '/Render/Display'
})
export class DemoComponent implements OnInit {
ngOnInit() { /* Initialization logic */ }
}
@{ Layout = null; }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Display Page</title>
<script type="text/javascript">
function modifyContent() {
document.getElementById('result').innerText = 'Content updated using JS';
}
</script>
</head>
<body onload="modifyContent();">
<div>
<h2>MVC Rendered View</h2>
<p id="result">Original Text</p>
</div>
</body>
</html>