- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个错误让我抓狂,我需要帮助。
Syntax Error: Token '{' invalid key at column 2 of the expression [{{ field }}.$error] starting at [{ field }}.$error].
<div class='row form-group' ng-form="{{ field }}" ng-clase="{ 'has-error': {{ field }}.$dirty && {{ field }}.$invalid }">
<label class='col-sm-2 control-label'> {{ field | labelCase }} <span ng-if='required'>*</span></label>
<div class='col-sm-6' ng-switch='required'>
<input ng-switch-when='true' ng-model='record[field][0]' type='{{ record[field][1] }}' class='form-control' required ng-change='update()' ng-blur='blurUpdate()' />
<div class='input-group' ng-switch-default>
<input ng-model='record[field][0]' type='{{ record[field][1] }}' class='form-control' ng-change='update()' ng-blur='blurUpdate()' />
<span class='input-group-btn'>
<button class='btn btn-default' ng-click='remove(field)'><span class='glyphicon glyphicon-remove-circle'></span></button>
</span>
</div>
</div>
<div class='col-sm-4 has-error' ng-show='{{ field }}.$dirty && {{ field }}.$invalid' ng-messages='{{ field }}.$error'>
<p class='control-label' ng-messages='required'> {{ field | labelCase }} is required. </p>
<p class='control-label' ng-repeat='(k, v) in types' ng-messages='{{ k }}'> {{ field | labelCase }} {{ v[1] }} </p>
</div>
</div>
angular.module('ContactsApp')
.value('FieldTypes', {
text: ['Text', 'should be text'],
email: ['Email', 'should be email'],
number: ['Number', 'should be number'],
date: ['Date', 'should be date'],
datetime: ['Datetime', 'should be datetime'],
time: ['Time', 'should be time'],
month: ['Month', 'should be month'],
week: ['Week', 'should be week'],
url: ['URL', 'should be URL'],
tel: ['Phone Number', 'should be phone number'],
color: ['Color', 'should be color']
})
.directive('formField', function ($timeout, FieldTypes) {
return {
restrict: 'EA',
templateUrl: 'views/form-field.html',
replace: true,
scope: {
record: '=',
field: '@',
live: '@',
required: '@'
},
link: function ($scope, element, attr) {
$scope.types = FieldTypes;
$scope.remove = function (field) {
delete $scope.record[field];
$scope.blurUpdate();
};
$scope.blurUpdate = function () {
if ($scope.live !== 'false') {
$scope.record.$update(function (updatedRecord) {
$scope.record = updatedRecord;
});
}
};
var saveTimeout;
$scope.update = function () {
$timeout.cancel(saveTimeout);
saveTimeout = $timeout($scope.blurUpdate, 1000);
};
}
};
});
<p>
<input type='search' class='form-control' placeholder='Search' ng-model='query'/>
</p>
<table class='table table-hover table-bordered'>
<thead>
<tr>
<th ng-repeat='field in fields' ng-click='sort(field)'>
{{ field | labelCase }}
<span ng-show='sort.field === field && !sort.order' class='glyphicon glyphicon-chevron-down'></span>
<span ng-show='sort.field === field && sort.order' class='glyphicon glyphicon-chevron-up'></span>
</th>
</tr>
</thead>
<tbody>
<tr ng-click='show(contact.id)' ng-repeat='contact in contacts | filter: query | orderBy: sort.field : sort.order'>
<td ng-repeat='field in fields'>
{{ contact[field][0] }}
</td>
</tr>
</tbody>
</table>
留给我,没有语法错误。知道为什么会这样吗?
最佳答案
当 {{ field }}.$error
第一次求值时 {{ field }}
还没有被插值,所以 Angular 将第一个 { 解释为开始一个对象声明和第二个作为键。在第一个摘要循环之后它起作用了,因为它已被插入到 whatever.$error
。
绝对不需要 {{ field }}
。使用 ng-form="form"
,将 {{ field }}
替换为 form
并从 remove()< 中删除参数
(没有双关语意)。表单对象的名称完全无关紧要。
关于javascript - 错误 : $parse:syntax Syntax Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32811128/
我不知道为什么我得到这些结果。 ++ +add +syntax error 2 ++ +add +syntax error 4 ++是我的输入,并且lex会回显每个字符,并且每当获得+时yacc打印就
这个问题在这里已经有了答案: Syntax error on print with Python 3 [duplicate] (3 个回答) 关闭8年前。 为什么 Python 在第 9 行的简单 p
我有一个非常简单的 SQL 语句 SELECT * FROM Table; 但是,我的查询引擎返回一个语法错误。为什么? 错误详情: An unhandled exception of type 'S
我正在尝试编写一些代码来模拟具有两个三态缓冲器和VHDL中的上拉电阻的电路。下面是我的代码: library ieee; use ieee.std_logic_1164.all; entity Pul
我已经编写了这个mergesort实现,如果将除法功能放在mergesort函数之外,效果很好。但是,当我尝试使除法成为mergesort的内部函数时,遇到语法错误。 我知道,对此必须有一些非常简单的
(我是 Linux 和 Vim 新手,我正在尝试学习 Vim,但我遇到了一些无法解决的问题) 我安装的 Linux (Ubuntu 8.04) 无法使用 Vim 7.1.138 进行更新。 我的 vi
这个错误让我抓狂,我需要帮助。 Syntax Error: Token '{' invalid key at column 2 of the expression [{{ field }}.$erro
原标题是“特定于语言的配色方案防止较简单的配色方案为某些特定于语言的标签着色” 我正在使用 gVim 7.3(在 Ubuntu 12.04 Arch x86/64 上,这很重要)。 更新(2013-0
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
我正在编写某种“编译器”:它读取游戏的描述(包括房间,角色,事物等)。将其视为冒险类游戏的视觉版本,但存在很多简单问题。 当我运行“编译器”时,输入中出现语法错误,我不知道为什么。这是我的yacc输入
我正在构建一个示例应用程序(请参阅plunk https://plnkr.co/edit/vDXcSPrOjw5qvBQKcYvw?p=preview)。 var myA
语法错误文件: 我想知道在哪里可以看到确切的错误信息。vivado中没有任何提示。 谢谢! 最佳答案 通常,您可以检查屏幕底部的消息选项卡。无论如何,Vivado并不是特别擅长告诉您代码有什么问题(我
您好,这是我的迷你编程语言的野牛语法文件: %{ #include #include #include #include "projectbison.tab.h" void y
Fmax我的代码中的参数报告为:No Paths to report .因此,我试图使用 set_input_delay 设置与定义时钟的输入信号关系。 .但是,错误报告指出: Verilog HDL
我正在开发一个使用 Twig 的 Symfony2 项目,文件类型为 myfile.html.twig。 Vim 不会自动检测语法突出显示,因此不应用任何语法。打开文件后,我可以使用 :set syn
这是一个相对简单的代码,用于“在半径为2个单位的圆象限上使用中坐标规则评估pi”。 main.alg BEGIN REAL x, y, sumy, pi; INT n := lowerlimit, p
我对我的简单插入所产生的错误感到非常困惑。我已经通过不同的检查器多次检查了语法并搜索了类似的问题,但没有找到解决方案。 错误看起来像这样: 'SQLSTATE[42000]: Syntax error
我尝试了以下代码: with x as 1: y = 1 with z as 1: w = 1 编译器报告了 SyntaxError:语法无效。有什么问题? [已编辑:]我想做的是:
我在 Webstorm 中使用 vue 框架,使用 ES6 语法。 我已经安装了 vue-for-idea 插件,如果我使用纯 ES5 语法,一切都会很顺利。 但是代码的ES6部分似乎还没有被识别,并
我将我认为有用的代码示例作为文本文件保存在我的计算机上。我将它们存储为 txt 文件而不是编写它们的语言,以便它们将在 Notepad++ 中打开而不是在编辑器中打开(即我不希望我的 c++ 示例在
我是一名优秀的程序员,十分优秀!