ng类的angularjs语法错误
angularjs syntax error with ng-class
我是angularjs(以及一般编程)的新手,遇到了麻烦。我将跟随一个教程,尝试创建一个表,并在单击时高亮显示特定的行。我的控制台正在记录一个错误,单击该错误后,我会看到这里:语法错误:令牌"undefined"位于表达式[{3}]的第{2}列,从[{4}]开始。控制台中的原始错误为:[$parse:syntax]http://errors.angularjs.org/1.2.23/$parse/syntax?p0=未定义&p1=是%20意外%2C%20预期%20%5B%7D%5D&p2=空&p3=%7Bselected%3A%20%24索引%3D%3selectedRow&p4=%7已选择%3A%20%24索引%3D%3SelectedRow
app.js
app.controller('RestaurantTableController',['$scope', function ($scope){
$scope.selectedRow = {};
$scope.directory= [{name:'The Handsome Heifer', cuisine:'BBQ'},
{name: "Green's Green Greens", cuisine:'Salads'},
{name:'House of Fine Fish', cuisine: 'Seafood'}];
$scope.selectRestaurant=function(row){
console.log('restaurant test');
$scope.selectedRow = row;
};
}]);
index.html:
<table ng-controller="RestaurantTableController">
<tr ng-repeat="restaurant in directory" ng-click ='selectRestaurant($index)' ng-class='{selected: $index==selectedRow'>
<td>{{restaurant.name}}</td>
<td>{{restaurant.cuisine}}</td>
</tr>
</table>
看起来您错过了ng类值中的右大括号:
ng-class='{selected: $index==selectedRow}'
相关文章:
- 错误:语法错误,无法识别的表达式:不支持的伪:无效/RectJS/Unit Testing
- 未捕获错误:语法错误,无法识别的表达式:input[@type=submit]
- jQuery AJAX Post方法错误(语法错误)
- 如何“;修复解析错误:语法错误,意外'{'in”用于php
- 错误:错误:语法错误,无法识别的表达式:
- 未捕获错误:语法错误,无法识别的表达式:ajaxsample/update_agenda(CodeIgniter)
- 未捕获错误:语法错误,无法识别表达式Jquery选择器单引号与双引号
- Javascript ( jQuery ) 错误: 语法错误: 缺少 ) 在参数列表之后
- 错误:语法错误:令牌“”,“”是意外的标记
- 未捕获的错误:语法错误,无法识别的表达式:输入:复选框[名称=ninja_forms_field_57[术语]]
- 未捕获的错误:语法错误,无法识别的表达式:“.b-brand-box”
- 未捕获的错误:语法错误,无法识别的表达式:href
- ReactJS 返回解析器错误语法错误:在 AJAX 调用 JAVA servlet 后出现意外的标记 a
- jQuery:未捕获错误:语法错误,无法识别的表达式
- j查询错误 - 语法错误:缺少:在属性 ID 之后
- 在使用 Gulp 在 javascript 中声明对象时,在 Git bash 中出现以下错误“语法错误:意外标识符”
- 获取未捕获错误:语法错误、无法识别的表达式
- 获取错误语法错误:属性列表 url 后缺少 }:http://localhost/mcportal/public/pos
- 为什么我收到错误“语法错误:非法字符”
- 未捕获错误:语法错误,无法识别的表达式