khan4019 / tree-grid-directive

Need one or more maintainer for this! comment or email me if you are interested
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
347 stars 183 forks source link

Error with cell template & cell template scope #77

Closed juniorkidza1994 closed 8 years ago

juniorkidza1994 commented 8 years ago

I have error follow this: Error: [$parse:ueoe] http://errors.angularjs.org/1.4.7/$parse/ueoe?p0=cellTemplateScope.click( at Error (native) at http://192.168.174.138:3000/lib/angular/angular.min.js:6:416 at Object.s.peekToken (http://192.168.174.138:3000/lib/angular/angular.min.js:210:131) at Object.s.parseArguments (http://192.168.174.138:3000/lib/angular/angular.min.js:207:467) at Object.s.primary (http://192.168.174.138:3000/lib/angular/angular.min.js:206:489) at Object.s.unary (http://192.168.174.138:3000/lib/angular/angular.min.js:205:503) at Object.s.multiplicative (http://192.168.174.138:3000/lib/angular/angular.min.js:205:249) at Object.s.additive (http://192.168.174.138:3000/lib/angular/angular.min.js:205:76) at Object.s.relational (http://192.168.174.138:3000/lib/angular/angular.min.js:204:416) at Object.s.equality (http://192.168.174.138:3000/lib/angular/angular.min.js:204:241) <span ng-click="cellTemplateScope.click(" example')'="">

my code in js is

     $scope.col_defs = [

      {
        field: "Type",
        displayName: "Type"
      },

      {
        field: "Email",
        displayName: "Email Address",
        cellTemplate: '<span ng-click="cellTemplateScope.click("example")">{{ row.branch[col.field] }}</span>',
        cellTemplateScope: {
            click: function(data) {         // this works too: $scope.someMethod;
                console.log(data);
            }
        }
      }
    ];

my code in html is

how can i fix this error ?

TrueDub commented 8 years ago

This is caused by passing a constant string - "example" - rather than an AngularJS variable e,g, row,branch. The single/double quotes are causing the span element to be truncated, thus meaning the click function isn't closed properly.

Because the cellTemplate is specified in javascript rather than HTML, I'm not sure of an easy solution. The case of passing constant strings is an unusual one though, so I don't think a solution is really required.

I'm going to close this issue now, as it's not specific to the directive.