我在数据库表字段有:Id,Organisation,Info.
我想要像这样制作dropdowm列表:
<select>
<option value='Id there'>'Organisation there'</option>...
Run Code Online (Sandbox Code Playgroud)
我试着用ViewBag做到这一点:
ViewBag.Organisations = db.Organisations.ToList(); // get all fields from table using dbContext
Run Code Online (Sandbox Code Playgroud)
在视图中:
@Html.DropDownList('I don`t know what i shoud write here, please help')
Run Code Online (Sandbox Code Playgroud)
我如何建立下拉列表?
我想从视图中获取本机元素和相关组件的列表。
我会尝试做类似的事情,但这是行不通的:
@ViewChildren('element', { read: [ElementRef, MyComponent] }) private elements: QueryList<any>; // <-- not work
or
@ViewChildren('element', { read: MyComponent }) private elements: QueryList<MyComponent>;
...
this.elements.first.nativeElement // <-- undefined
Run Code Online (Sandbox Code Playgroud)
这项工作,但它看起来不对:
@ViewChildren('element', { read: ElementRef }) private elements: QueryList<ElementRef>;
@ViewChildren('element', { read: MyComponent}) private components: QueryList<MyComponent>;
Run Code Online (Sandbox Code Playgroud)
我的模板简短示例:
<virtual-scroller #scroll>
<my-component #element *ngFor="let c of components"></my-component>
</virtual-scroller>
Run Code Online (Sandbox Code Playgroud) 我的按钮被标签栏剪切了。我该如何解决这个问题?
我尝试为所有标签添加“溢出:可见”,但它不起作用。
我的模板:
.place-button-wrapper{
position: absolute;
bottom: 20px;
}Run Code Online (Sandbox Code Playgroud)
<ion-tabs>
...
<ion-tab-button tab="places">
<div class="place-button-wrapper" >
<img class="tabs-icon" src="assets/icons/mapiconelepse.png" alt="">
</div>
</ion-tab-button>
...
</ion-tabs>Run Code Online (Sandbox Code Playgroud)
在代码中,我使用 ViewChild 引用了我的 DOM 元素。
但是如果我尝试在 ngAfterViewInit 钩子中检查这个元素,我会发现我的元素的 offsetHeight 和 offsetWidth 为零。(有时一切都好)
我认为这是因为我创建的元素尚未在 Dom 中渲染?
有什么办法解决这个问题吗?我正在使用离子4。
HTML:
<div id="map" #map [style.height.px] = "'300'" [style.width.px]="'100'"></div>
Run Code Online (Sandbox Code Playgroud)
TS:
...
map: any;
@ViewChild('map') mapElement: ElementRef;
ngAfterViewInit() {
this.loadMap();
}
loadMap() {
//usually return 0
console.log('height:' + this.mapElement.nativeElement.offsetHeight);
console.log('width:' + this.mapElement.nativeElement.offsetWidth);
this.map = DG.map(this.mapElement.nativeElement);
}
...
Run Code Online (Sandbox Code Playgroud)
我期望高度为 300,宽度为 100。
我有一个枚举类“ Figure”和脚本:
public enum Figure { X, O }
private Figure[,] board = new Figure[boardSize, boardSize];
Run Code Online (Sandbox Code Playgroud)
当板上没有任何值时,我要向板上添加空值。示例:
board[0,0] = null-但这是错误的。我该怎么做?
angular ×3
c# ×2
javascript ×2
typescript ×2
arrays ×1
asp.net ×1
asp.net-mvc ×1
css ×1
dom ×1
ionic4 ×1
leaflet ×1