0

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 }]} 
         </td>
         <td>
             <button type="button" class="btn btn-default" ng-click="$ctrl.open({[{ record.KeyNum }]})">Open me!</button>
         </td>
          <td> 
               <button>Edit</button> <button>Delete</button>
         </td>
    </tr>

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) {
          httpFactory.getRecord(keyNum).then(
              function(response) {
                  $ctrl.items = response.data[0];
              },
              function(response) {
                  console.log(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

 "$ctrl.open(record.KeyNum)"

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

12
  • what is $ctrl here? Commented Sep 6, 2016 at 17:17
  • 4
    Do you maybe just want $ctrl.open(record.KeyNum)? Commented Sep 6, 2016 at 17:19
  • $ctrl is this and this is the controller that the function lives in. I'll update it so that is more clear. Essentially I am following the example given for ui- bootstrap Commented Sep 6, 2016 at 17:20
  • @smarx I don't think that would would work as the record is a object. Once again I'll update to give more context. Commented Sep 6, 2016 at 17:25
  • Does it matter that you have an uppercase "K" in the markup and a lowercase "k" in the resolve section? Commented Sep 6, 2016 at 17:26

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.