rpiper rpiper - 6 months ago 20
AngularJS Question

How do I resolve this syntax error caused by .?

The error message I am getting is:

Syntax Error: Token '.' is unexpected, expecting [}] at column 23 of the expression [] starting at [{4}].

The offending html that is causing the issue.

<tr ng-repeat="record in key_table">

<td ng-repeat="data in record">
{[{ data }]}
<button type="button" class="btn btn-default" ng-click="$ctrl.open({[{ record.KeyNum }]})">Open me!</button>
<button>Edit</button> <button>Delete</button>

The open function in angularjs:

angular.module('KeyManager').controller("KeyController", function( httpFactory, $uibModal) {
$ctrl = this;
$ctrl.open = function () {
var modalInstance = $uibModal.open({
animation: true,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl: 'RecordViewer.html',
controller: 'RecordViewerInstanceCtrl',
controllerAs: '$ctrl',
size: "lg",
resolve: {
items: function (keyNum) {
function(response) {
$ctrl.items = response.data[0];
function(response) {
$ctrl.items = [];
return $ctrl.items;

Also, note that I am doing this in a twig file so start and and end symbols have been changed to "{[{" and "}]}" respectively.

Added Information:

I have tried switching the ng-click directive to


but this only prints out the literal string record.KeyNum which is explain here so @smarx comment is the answer.


I think you just want $ctrl.open(record.KeyNum).