angularjs - Angular compile template error on local project and jsFiddle, but working fine in Plunker -
i've noticed angular controller growing , have been trying refactor , use directives , services.
however, on 1 scenario, trying create directive appears working fine in plunker, seeing following error in local application , in jsfiddle:
error: [$compile:tplrt] http://errors.angularjs.org/1.2.8/$compile/tplrt?p0=getemptycells&p1=
plunker link: http://plnkr.co/edit/e11za8lkvoptgtqw2hee?p=preview
jsfiddle link (error can seen in firebug): http://jsfiddle.net/oampz/8hq3r/14/
directive:
app.directive('getemptycells', function () { return { restrict: 'ea', replace: true, template: '<td ng-repeat="emptycell in getemptycells(payments.details.length)" class="empty">no payment</td>', scope: { 'payments' : '=getemptycells' }, link: function (scope, elem, attr) { scope.getemptycells = function (len) { var emptycells = []; (var = 0; < 12 - len; i++) { emptycells.push(i); } return emptycells; }; } }; });
html:
<table> <tr>with directive:</tr> <tr ng-repeat="payments in mypayments"> <th>{{payments.name}}</th> <td ng-repeat="paymentamount in payments.details.slice(0, 12)">{{ paymentamount }}</td> <td get-empty-cells="payments"></td> </tr> </table>
when remove:
template: '<td ng-repeat="emptycell in getemptycells(payments.details.length)" class="empty">no payment</td>',
the error disappears, naturally expected functionality/output not produced.
i'm confused @ cause this.
i think problem jsfiddle creates. service jsfiddle or plunker have trouble emulating real setup while still providing features embedded output, external file loading etc. solutions seem work better others, , while i've been loving user of jsfiddle long - angularjs projects seem work lot better in plunker, angular template can select @ start.
i think question why doesn't work question of why jsfiddle can't make work, , though i'd hate answer question "that doesn't matter", think should focus on solving problems , not jsfiddle's problem , use service (like plunker) ;)
edit: if guess (generally not idea so) i'd jsfiddle somehow messes template adding perhaps comment node template, breaking "one rootnode" requirement angular template.
Comments
Post a Comment