我在模板系统内部工作并尝试使用 Angular.js。我需要将 ng-app 添加到 html 元素,但无权直接在页面上执行此操作。所以基本上我的页面是这样开始的:
<html>
我希望它看起来像这样:
<html ng-app>
我确实有权向页面添加 javascript。
有没有办法添加javascript来告诉页面发生变化
<html> to <html ng-app>
最佳答案
您可以手动初始化 Angular ,如 docs 中所示:
/* in your js file */
angular.element(document).ready(function() {
angular.module('myApp', []);
angular.bootstrap(document, ['myApp']);
});
关于javascript - 如何在不访问 html 的情况下将 ng-app 添加到 html 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21192332/