Angular 无法从中的ng引导库获取属性值

Angular 无法从中的ng引导库获取属性值,angular,ng-bootstrap,Angular,Ng Bootstrap,目前我正在使用ng bootstrap datepicker并尝试从ngb datepicker month组件获取属性值“aria label”,但我无法直接访问DOM,但是我尝试使用jQuery,但它没有获取值。有没有办法在ng datepicker库中获取attr值 打字稿: ngOnInit() { $(document).ready(() => { console.log('arial-label: ',$('.ng

目前我正在使用ng bootstrap datepicker并尝试从ngb datepicker month组件获取属性值“aria label”,但我无法直接访问DOM,但是我尝试使用jQuery,但它没有获取值。有没有办法在ng datepicker库中获取attr值

打字稿:

    ngOnInit()
      {
        $(document).ready(() => {
    
    
    console.log('arial-label: ',$('.ngb-dp-week .hidden').get('aria-label'));
        
        function formtDate(date) {
            var d = new Date(date),
            day = <any>d.getDate();

            if(<any>day.length < 2) {
              day = day;
            }
            return day;
          }
          console.log(formtDate("Moday, October 8, 2020"));
        });
  }
ngOnInit()
{
$(文档).ready(()=>{
log('arial-label:',$('.ngb dp week.hidden').get('aria-label');
函数formtDate(日期){
var d=新日期(日期),

day=

您可以使用
ViewChild
。尝试以下操作:

app.component.html


应用程序组件.ts


从“@angular/core”导入{Component,ViewChild,ElementRef};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:[“/app.component.css”]
})
导出类AppComponent{
//获取参考资料
@ViewChild(ariaLabel,{static:false})div:ElementRef;
ngAfterViewInit(){
console.log(this.div.nativeElement);
}
}

谢谢@ng hobby,但我的页面上有20多个aria标签。如何定位特定的标签?正如您所看到的,在特定的分区上有一个templateReference`#ariaLabel`,我同意,但在我的情况下有所不同,因为HTML是不可访问的,并且它是从ng引导中填充的。我正在尝试获取不可编辑的组件t属性,但您可以将组件放在容器div上,并使用
ViewChildren
而不是
ViewChildren
。请参阅本文: