小编I.B*_*ond的帖子

使用ViewBag的Asp.net mvc下拉列表

我在数据库表字段有: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)

我如何建立下拉列表?

c# asp.net asp.net-mvc drop-down-menu

7
推荐指数
2
解决办法
2万
查看次数

有什么方法可以在 ViewChildren 中获取 ElementRef 和 Component ref?

我想从视图中获取本机元素和相关组件的列表。

我会尝试做类似的事情,但这是行不通的:

@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)

javascript dom angular

7
推荐指数
2
解决办法
3618
查看次数

Ionic 4 标签栏溢出

我想要这样的布局:在此输入图像描述

但得到这个:在此输入图像描述

我的按钮被标签栏剪切了。我该如何解决这个问题?
我尝试为所有标签添加“溢出:可见”,但它不起作用。
我的模板:

.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)

css typescript ionic-framework angular ionic4

6
推荐指数
1
解决办法
2295
查看次数

原生元素的大小为零

在代码中,我使用 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。

javascript leaflet typescript ionic-framework angular

5
推荐指数
1
解决办法
1613
查看次数

将空值设置为枚举C#的数组

我有一个枚举类“ Figure”和脚本:

public enum Figure { X, O }

private Figure[,] board = new Figure[boardSize, boardSize];
Run Code Online (Sandbox Code Playgroud)

当板上没有任何值时,我要向板上添加空值。示例: board[0,0] = null-但这是错误的。我该怎么做?

c# arrays

-3
推荐指数
1
解决办法
292
查看次数