Javascript 角形图案会导致绑定中断
我有一张表格:Javascript 角形图案会导致绑定中断,javascript,angularjs,Javascript,Angularjs,我有一张表格: <div class="panel-group"> <label for="url" tooltip="Enter the Engine as a Web Service (EWS) URL the Empower Editor will use for PDF preview.">EWS URL</label> <input id="url" size="50" ng-model="config.ewsUrl" requ
<div class="panel-group">
<label for="url" tooltip="Enter the Engine as a Web Service (EWS) URL the Empower Editor will use for PDF preview.">EWS URL</label>
<input id="url" size="50" ng-model="config.ewsUrl" required ><br/>
<label for="PreviewTimeout" tooltip="Specify how long the Empower Editor will wait for a response from the PDF preview.">Preview timeout (Seconds)</label>
<input id="PreviewTimeout" type="number" min="15" max="60" required ng-model="config.previewTimeout" style="width: 150px;">
</div>
EWS网址
预览超时(秒)
当我向输入添加ng模式属性时,它会破坏绑定:
<div class="panel-group">
<label for="url" tooltip="Enter the Engine as a Web Service (EWS) URL the Empower Editor will use for PDF preview.">EWS URL</label>
<input ng-pattern="/^((ht|f)tp(s?)\\:\\/\\/)?[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\,\\:\\'\\/\\\\\\+=&%\\$#_]*)?$/" id="url" type="url" size="50" ng-model="config.ewsUrl" required><br/>
<label for="PreviewTimeout" tooltip="Specify how long the Empower Editor will wait for a response from the PDF preview.">Preview timeout (Seconds)</label>
<input id="PreviewTimeout" type="number" min="15" max="60" required ng-model="config.previewTimeout" style="width: 150px;">
</div>
EWS网址
预览超时(秒)
如果我删除reg-ex,它将再次返回绑定。什么原因可能导致这种情况?看起来您正在尝试验证url。对此,您不需要使用正则表达式或
ng模式
选项。相反,只需使用以下内容:
<input type="url" id="url" type="url" size="50" ng-model="config.ewsUrl" required/>
祝你好运 看起来您正在尝试验证url。对此,您不需要使用正则表达式或
ng模式
选项。相反,只需使用以下内容:
<input type="url" id="url" type="url" size="50" ng-model="config.ewsUrl" required/>
祝你好运 我很确定这是因为你的正则表达式无效。你为什么有这么多双反斜杠?仅在创建新的
RegExp
对象时使用这些。您使用的是文字符号(/stuff/
)。如果将正则表达式移动到控制器并删除反斜杠,则它可以工作:。此外,如果您只是修复属性中的正则表达式,它似乎也起作用:我很确定这是因为您的正则表达式无效。你为什么有这么多双反斜杠?仅在创建新的RegExp
对象时使用这些。您使用的是文字符号(/stuff/
)。如果将正则表达式移动到控制器并删除反斜杠,则它可以工作:。此外,如果您只是修复属性中的正则表达式,它似乎也能起作用:这在不支持type=“url”
的浏览器中有效吗?我不这么认为。我认为这就是ng模式的要点specifically@Ian说得好。这将适用于IE10和更新版本,以及除Safari per之外的所有其他“现代”浏览器。我将用一个工作模式更新我的答案,以确保旧版本的浏览器支持很重要。这在不支持type=“url”
的浏览器中有效吗?我不这么认为。我认为这就是ng模式的要点specifically@Ian说得好。这将适用于IE10和更新版本,以及除Safari per之外的所有其他“现代”浏览器。我将用一个工作模式更新我的答案,以确保旧的浏览器支持很重要。