我试图通过在 typescript 2.1 中获取元素 ID 来禁用一个字段。我在打字稿 1.5 的下面找到了这个语法。但它在 2.1 中不起作用。任何人都可以帮忙。
( document.getElementById('BenchForcastId_'+valueID)).disabled = false;
我正在开发一个项目,他们使用 $$ 来选择 id/class。我对此不太确定。谁能告诉我这是什么意思。我用谷歌搜索了一下。但没有得到正确的答案。
$$("#" + idName + "text").setStyle('background', '#000');
Run Code Online (Sandbox Code Playgroud) 下面是我的文件夹结构。
app
- common
- header
header.component.css
header.component.html
header.component.ts
- footer
footer.component.css
footer.component.html
footer.component.ts
- index
index.component.css
index.component.ts
index.component.html
index.module.ts
- lessons
lesson1(another folder)
lesson2(folder)
lesson.module.ts
app.component.css
app.component.ts
app.component.html
app.module.ts
Run Code Online (Sandbox Code Playgroud)
我已经在app.module中导入了页眉和页脚组件,index.module,lesson.module并使用
<app-header></app-header>
<app-navbar></app-navbar>
Run Code Online (Sandbox Code Playgroud)
在index.component.html,lesson1.component.html,lesson2.component.html中。
但是我发现“ app-header”不是已知的元素错误。有人可以帮助我解决此错误吗?
如果我直接在index.module.ts中包含页眉和页脚组件,它将很好地工作
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router';
import * as $ from 'jquery';
import { AppComponent } from …Run Code Online (Sandbox Code Playgroud) 我用过ngFor来显示我的数据.如果来自ngFor的变量值为空/未定义,我想隐藏div.我的代码如下.任何人都可以帮忙.
<li *ngFor="let parcel of dataSource;">
<span hidden="parcel.ID==''">{{parcel.refrence }}</span>
</li>
Run Code Online (Sandbox Code Playgroud) 我试图读取锚标记的'aria-label'属性.但我得到空值,因为我的代码读取子元素(<use></use>)而不是父元素(<a></a>).下面是我的HTML和js代码.
HTML
var inputs = document.querySelectorAll("a");
for (var i = 0; i < inputs.length; i++) {
inputs[i].addEventListener("click", function(e) {
console.log(inputs[i].getAttribute("aria-label"));
});
}Run Code Online (Sandbox Code Playgroud)
<a href="#" role="menuitem" id="main-6" aria-haspopup="true" aria-label="Choose your country site">
<svg class="header-redirect--icon-w">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-country"></use>
</svg>
<i class="i-globe-w"></i>
</a>Run Code Online (Sandbox Code Playgroud)
页面中没有路由。我在下面使用了HTML和配置代码。
<nav aria-label="Page navigation">
<ul class="pagination pagination-plain">
<li>
<a href="review/words" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/words">1</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/phrase">2</a>
</li>
<li>
<a href="javascript:void(0)" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
Run Code Online (Sandbox Code Playgroud)
路由配置代码为
const appRoutes: Routes = [
{
path: '',
component: IndexComponent,
},
{
path: 'index',
component: IndexComponent,
},
{
path: 'review/words',
component: WordsComponent,
},
{
path: 'review/phrase',
component: SentenceComponent,
}
];
Run Code Online (Sandbox Code Playgroud)
当我在分页链接中单击“ 1”或“ 2”时,出现以下错误。
错误错误:未捕获(承诺):错误:无法匹配任何路由。URL段:'review / phrase / NaN'错误:无法匹配任何路由。网址段:ApplyRedirects.noMatchError(router.es5.js:1404)的[review / phrase / NaN]在CatchSubscriber.selector的[角度](router.es5.js:1379)在CatchSubscriber.error的[角度](catch.js) :104)在MapSubscriber.Subscriber._error(Subscriber.js:128)的[angular]在MapSubscriber.Subscriber.error(Subscriber.js:102)的[Angular]在MapSubscriber.Subscriber._error(Subscriber.js:128)的[angular] )[Subscriber.Subscriber.error(Subscriber.js:102)的[Angular] …
angular ×3
javascript ×2
angularjs ×1
hidden ×1
html ×1
jquery ×1
label ×1
routerlink ×1
typescript ×1