我如何在Map对象上使用双向绑定?
以下代码无法按预期工作:
零件:
@Component({
moduleId: module.id,
selector: "my-component",
templateUrl: "my-component.html",
styleUrls: ["my-component.scss"],
})
export class MyComponent {
myMap: Map<string, Object> = Map<string, Object>()
.set('first', {text: 'abc'})
.set('second', {text: 'foo'})
;
}
Run Code Online (Sandbox Code Playgroud)
模板:
<div class="items" *ngFor="let item of myMap.values()">
<input type="text" [(ngModel)]="item.text" />
</div>
Run Code Online (Sandbox Code Playgroud) 我有一些发送simular数据的js脚本:
$.ajax({
type: "POST",
url: '/manage/add-shops/',
data: {'id':id, 'shops': shops}
Run Code Online (Sandbox Code Playgroud)
'shops'是〜1000个元素的数组,所以我应该通过POST发送它.我有一个yii2控制器方法:
class ManageController extends Controller {
public function actionAddShops($id, $shops=array()) {
....
}
Run Code Online (Sandbox Code Playgroud)
路由是好的,但我收到此错误:
"Missing required parameters: id"
Run Code Online (Sandbox Code Playgroud)
它看起来像POST params没有映射到方法参数.谢谢.
我没有找到有关 xxhash64 冲突百分比的任何信息。
我将把它用于缓存系统(生成需要唯一的哈希键,大约数亿个)。现在我使用 md5,但我不需要加密属性。
所以我需要一些信息来决定这对我的任务来说是否是一个好的决定。最好的情况 - 比较 md5 和 xxHash64 之间的冲突次数。
在perl中所有sub的参数写入@_数组,如下所示:
call_any_sub($a,$b,$c);
sub call_any_sub {
my $s_a = shift;
my $s_b = shift;
my $s_c = shift;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我想将数组作为参数传递给sub,我应该使用:
call_any_sub(@data_array);
sub call_any_sub {
my @data = @_;
}
Run Code Online (Sandbox Code Playgroud)
而不是类似的:
call_any_sub(@data_array);
sub call_any_sub {
my @data = shift;
}
Run Code Online (Sandbox Code Playgroud)
那么,为什么@data_array会替换参数数组而不是写入(正如预期的那样)?