我试图获得一个角度ng模式来检查用户名没有空格或特殊字符.如果输入空格或特殊字符,则以下形式返回false.但是,只要输入az,Az或0-9,它就会变为真.我试过ng-pattern ="/ [^\s] + /"和\ S和[^],但它们没有区别.
<form name="myform">
valid? {{ myform.$valid }}
<input type="text" name="username" ng-model="username" ng-pattern="/[a-zA-Z0-9^ ]/" required/>
</form>
Run Code Online (Sandbox Code Playgroud)
这是插件中的表格:http://plnkr.co/edit/6T78kyUgXYfNAwB4RHKQ?p = preview
我刚刚在Laravel中测试了Eloquent ORM的性能,并且惊讶地发现一个简单的查询需要花费超过3秒的时间来执行,而普通的Laravel查询在0.1秒内完成.我只返回1500条记录.
DB::table('t_organisations')->get(); - 0.12253594398499 seconds
Organisation::all(); - 3.6389181613922 seconds
Run Code Online (Sandbox Code Playgroud)
当然这不正常!?我不认为我在设置中遗漏了任何东西.我的数据库已标准化.可能是什么问题呢?
我把这个问题分解成了最简单的形式.基本上我有一个指令,对于演示,还没有真正做任何事情.我有一个div作为属性的指令.div中的值(来自对象数组)不会显示.如果我从div中删除指令,它们会显示OK.我显然遗漏了一些非常明显的东西,因为我之前没有遇到任何问题.
这是Plunk:http://plnkr.co/edit/ZUXD4qW5hXvB7y9RG6sB?p=preview
脚本:
app.controller('MainCtrl', function($scope) {
$scope.tooltips = [{"id":1,"warn":true},{"id":2,"warn":false},{"id":3,"warn":true},{"id":4,"warn":true}];
});
app.directive("cmTooltip", function () {
return {
scope: {
cmTooltip: "="
}
};
});
Run Code Online (Sandbox Code Playgroud)
HTML
<div ng-repeat="tip in tooltips" class="titlecell" cm-tooltip="true">
A div element: {{ tip.id }}
</div>
<br><br>
Just to prove it works without the directive:
<div ng-repeat="tip in tooltips" class="titlecell">
A div element: {{ tip.id }}
</div>
Run Code Online (Sandbox Code Playgroud) 我正在努力创建一个 JSON 对象以通过网络发送。有问题的数组在 Chrome 调试器中看起来像这样。
event: Array[0]
$$hashKey: "02Q"
bolFromDB: 1
bolIndoor: null
classId: 41
curValue: "7.1000"
curWeightHeight: ""
datDate: "2013-01-13T01:00:00.000Z"
exists: true
id: "10"
idClass: "W"
idEvent: "60M"
length: 0
ownEvents: true
ownSex: true
pbs: undefined
selected: true
strAdditional: ""
strName: "60m"
strTown: "Stadtallendorf"
__proto__: Array[0]
Run Code Online (Sandbox Code Playgroud)
这是一个更大的对象数组的一小部分,但在尝试将问题分解为最小的部分时,这似乎是该行的结尾。
调用时JSON.stringify(event),返回值为[]。
我期望{$$hashKey: "02Q",bolFromDB: 1, bolIndoor: null, ... etc }