Reputation: 13915
I need to include into table a few tr element based on template prototype/views/prototype/booking/templates/table-row.html
. I use custom directive to indicate the point where template should be inserted. Also I define rownum
to show what value should be used while pasting template. This just simply don't do anything. How to make it work?
prototypeApplication.directive('tablerowtemplate', function() {
return {
restrict: 'E',
transclude: true,
scope: { rownum:'@' },
templateUrl: 'prototype/views/prototype/booking/templates/table-row.html'
};
});
booking
<table><tr><td>static entry</td></tr>
<tablerowtemplate rownum="1"></tablerowtemplate>
<tablerowtemplate rownum="2"></tablerowtemplate>
</table>
prototype/views/prototype/booking/templates/table-row.html
<tr>
<td>
<div class="form-group first-name">
<label>First name</label>
<input type="text" ng-class="{'input-valid': isValidField('FirstName', persons[{{rownum}}].firstName)}"
name="firstName" class="form-control input-name" ng-model="persons[{{rownum}}].firstName"
ng-focus="focused('inputFirstName', {{rownum}})" placeholder="-">
</div>
</td>
</tr>
UPDATE
No errors in console. All <tablerowtemplate rownum="1"></tablerowtemplate>
is not excist in html dom when rendered
UPDATE 2
When I try to generate a few cell
s I got only one:
<cell rownum="0"></cell>
<cell rownum="1"></cell>
<cell rownum="2"></cell>
<cell rownum="3"></cell>
prototypeApplication.directive('cell', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: { rownum:'@' },
templateUrl: 'prototype/views/prototype/booking/templates/table-row.html'
};
});
Does it mean that setting rownum="3"
makes template have {{rownum}} equals 3? Is it possible that value of attribute will tell template what value to inject into itself? How to fix it?
Upvotes: 0
Views: 61
Reputation: 19598
It'a an angular issue :( Read here: https://github.com/angular/angular.js/issues/1459
I also tried myself to write a simple directive and the behavior is odd!
Upvotes: 1