完整错误:
Uncaught Error: Parse error on line 139:
...rs" ng-class="{ '{{ playerClass(player)
-----------------------^
Expecting 'DATA', 'ID', got 'INVALID'
parseError @handlebars.js:2解析@handlebars.js:2 Handlebars.parse @handlebars.js:2 r @ handlebars.js:3(匿名 函数)@handlebars.js:3(匿名函数)@main.js:212 我@jquery.js:2 fireWith @jquery.js:2 ready @ jquery.js:2 J @ jquery.js:2
HTML:
<div class="float-left container-60 ">
<div class="align-center uppercase active-score cricket-table-container container-middle-table">
<table class="cricket-scoreboard">
<tr>
<th></th>
<th class="color-container-center" ng-repeat="no in numbersToClose track by $index" ng-class="{'bullseye-icon': no === 25 && !isNumberFullyClosed(no), 'bullseye-icon-closed': no === 25 && isNumberFullyClosed(no), 'btn-new-gold': no !== 25 && isNumberFullyClosed(no), 'btn-new-navy': no !== 25 && !isNumberFullyClosed(no) }">{{ no }}</th>
<th></th>
</tr>
<tr ng-repeat="player in players" ng-class="{ '{{ playerClass(player) }}': player.id === currentPlayer.id }">
<td class="{{ playerClass(player) }}"></td>
<td ng-repeat="no in numbersToClose track by $index" ng-class="{ 'btn-new-white': player.id === currentPlayer.id, '{{ playerClass(player) }}': player.id !== currentPlayer.id, 'cricket-hit-zero': [3, null].indexOf(player.numbersToHit[no]) !== -1, 'cricket-hit-one': player.numbersToHit[no] === 2, 'cricket-hit-two': player.numbersToHit[no] === 1, 'cricket-hit-three': player.numbersToHit[no] === 0 }"></td>
</tr>
</table>
</div>
</div>
Main.js:
Handlebars.registerHelper('color', function(ndx) {
if(typeof context === "undefined" || isNaN(ndx)){
return "";
}
return playerColors[ndx];
});
Handlebars.registerHelper('index_of', function(context,ndx,offset) {
if(typeof offset != "undefined" && !isNaN(offset)) {
ndx-=offset;
}
if(typeof context === "undefined" || isNaN(ndx)){
return "";
}
return context[ndx];
});
Handlebars.registerHelper('container_width', function(length) {
if(length === 4 || length === 7 || length === 8) {
return 'container-25'
}
if(length === 3 || length === 6 || length === 5) {
return 'container-33'
}
if(length === 2) {
return 'container-50'
}
if(length === 1) {
return 'container-100'
}
});
Handlebars.registerHelper('compare', function(lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
var operator = options.hash.operator || "==";
var operators = {
'==': function(l,r) { return l == r; },
'===': function(l,r) { return l === r; },
'!==': function(l,r) { return l !== r; },
'!=': function(l,r) { return l != r; },
'<': function(l,r) { return l < r; },
'>': function(l,r) { return l > r; },
'<=': function(l,r) { return l <= r; },
'>=': function(l,r) { return l >= r; },
'typeof': function(l,r) { return typeof l == r; }
}
if (!operators[operator])
throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+operator);
var result = operators[operator](lvalue,rvalue);
if( result ) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
Handlebars.registerHelper('if_all', function() {
var args = [].slice.apply(arguments);
var opts = args.pop();
var fn = opts.fn;
for(var i = 0; i < args.length; ++i) {
if(args[i])
continue;
fn = opts.inverse;
break;
}
return fn(this);
});
Handlebars.registerHelper("math", function(lvalue, operator, rvalue, options) {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
return {
"+": lvalue + rvalue,
"-": lvalue - rvalue,
"*": lvalue * rvalue,
"/": lvalue / rvalue,
"%": lvalue % rvalue
}[operator];
});
Handlebars.registerHelper("throw", function(value1, value2, value3, options) {
if(!value1 && !value2 && !value3) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
Handlebars.registerHelper("pull", function(value1, value2, value3, options) {
if(!value1 && value2 && value3) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
Handlebars.registerHelper("wait", function(value1, value2, value3, options) {
if(value1 || (value2 && !value3)) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
var template = Handlebars.compile(source);
我不确定这是什么问题。
答案 0 :(得分:1)
我无法看到playerClass
帮助定义。