如何在 ngMaterial 中禁用 ngAria? [英] How do I disable ngAria in ngMaterial?
问题描述
ngAria(一个辅助功能模块)向我的 Angular Material 项目添加了一个不必要的 bower 导入 - 现在它发出警告:
ngAria (an accessibility module) is adding an unnecessary bower import to my Angular Material project - and now it is throwing warnings:
节点上缺少可访问性所需的属性"aria-label "
Attribute " aria-label ", required for accessibility, is missing on node
我只添加了 ngAria,因为它似乎是 ngMaterial 所必需的.我的应用不需要屏幕阅读器辅助功能.
I only added ngAria because it appeared necessary for ngMaterial. My app does not need screen-reader accessibility.
无论如何,我怎样才能从 ngMaterial 中删除 ngAria?或者至少禁用所有警告.
Anyways, how can I remove ngAria from ngMaterial? or at least disable all warnings.
似乎禁用 ngAria 警告的唯一简单方法是 console.warn = function() {};
它将关闭浏览器的警告(我不建议这样做,因为它可能会隐藏与 aria 无关的警告)
It seems the only easy way to disable ngAria's warnings is console.warn = function() {};
which will just turn off your browser's warnings (I do not recommend doing this, since it may hide warnings unrelated to aria)
推荐答案
从 1.1.0 开始,可以全局禁用消息:
Disabling messages globally is possible as of 1.1.0:
app.config(function($mdAriaProvider) {
// Globally disables all ARIA warnings.
$mdAriaProvider.disableWarnings();
});
(但请注意其他答案中关于 aria 标签对可访问性很重要的讨论!)
(But do note the discussion in other answers about aria labels being important for accessibility!)
这篇关于如何在 ngMaterial 中禁用 ngAria?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!