html - 如何在 Angular 2+ 中显示 AngularJS
问题描述
我只想知道如何在 Angular 2+ 中显示 AngularJS(我有一个非常独特的情况需要这样做)
到目前为止,这是我尝试过的:
https://stackblitz.com/edit/angular-wbbzbz?file=src/app/app.component.ts
为了让您了解 stackblitz 上发生的事情:
我有一个基本的 html 字符串(我从这里得到:https://www.w3schools.com/angular/tryit.asp?filename=try_ng_default):
myHtml = `
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="">
<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
`;
通过管道,我使用以下方法显示它:
<div [innerHTML]="myHtml | pipeSanitizeHtml"></div>
但我最终得到了这个(破碎的AngularJS):
解决方案
如果您将其放在 Angular 2+index.html
的标题中,AngularJS 将起作用:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
推荐阅读
- python - 你可以在 tkinter 根窗口上写图像吗?
- css - 伪元素的背景剪辑和转换使其在 Chrome 中消失
- python - 如何在 CosmosDB SQL-API 中按日/月/年分组
- excel - DAX 中的 PowerBI DISTINCT SUMX
- python - Django 查询字符串提取字典
- stored-procedures - CosmosDB 存储过程 - 使用分区键进行搜索
- python - 无法在 Windows 上安装 PySimpleGUI “ModuleNotFoundError: No module named 'PySimpleGUI'”
- javascript - 如何将“删除按钮”附加到在 JS 中新创建的每个列表项?
- json - 解析 JSON 数据第 2 部分
- python - 新创建的工作表不断被删除 - Python/Pandas/Openpyxl