作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 AngularJS 中检索当前应用程序的名称?
我的意思是ng-app="foo"
值(value)。
我已经搜索了 API 文档,但找不到任何对此的引用。
我的解决方案
其实我找到了这样的解决方案
angular.element($('[ng-app]')).attr('ng-app');
最佳答案
来自 $rootElement文档:
The root element of Angular application. This is either the element where ngApp was declared or the element passed into angular.bootstrap.
<html ng-app="myApp">
...
app.controller('MyCtrl',
[
'$scope',
'$rootElement',
function($scope, $rootElement) {
console.log($rootElement.attr('ng-app')); // --> myApp
}
]
);
关于angularjs - 检索 AngularJS 应用程序名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17502055/
概述 CentOS Stream 成立于 2019 年,是“RHEL 下一步的滚动预览”。Red Hat 首席技术官 Chris Wright 和 CentOS 社区经理 Rich Bowen 各
我有一个使用 Mesosphere DC/OS 编排选项进行配置的 Azure 容器服务 (ACS) 集群。我可以在 Marathon UI 中创建一个应用程序。 但是,当我通过 Marathon U
我是一名优秀的程序员,十分优秀!