2016-09-06 20 views
0

我得到的錯誤信息是:如何解決由。引起的語法錯誤?

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

,導致該問題的違規HTML。

<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> 

open函數在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; 
     } 
    } 
    }); 
}); 

另外,注意,我在一個樹枝文件,這樣做所以開始並和結束符號已更改爲「{[{」和「} ]}「 分別。

添加的信息:

我曾嘗試切換NG-點擊指令

"$ctrl.open(record.KeyNum)" 

但這只是打印出的文字字符串record.KeyNum這是解釋here所以@smarx評論是答案。

+0

什麼是$ ctrl這裏? – Sajeetharan

+4

你可能只想'$ ctrl.open(record.KeyNum)'? – smarx

+0

$ ctrl是這個,這是函數所在的控制器。我會更新它,以便更清楚。本質上,我遵循[ui bootstrap]給出的示例(https://angular-ui.github.io/bootstrap/#/modal) – rpiper

回答

1

我想你只是想$ctrl.open(record.KeyNum)

相關問題