AngularJS equivalent for Angular ng-container
In cases you have mentioned, you can use ng-repeat-start
and ng-repeat-end
pair, respectively:
Tables with interlaced pairs, triples etc. of cells:
<table><tr> <td ng-repeat-start="item in items">{{ item.a }}</td> <td ng-repeat-end>{{ item.b }}</td></tr></table>
HTML lists:
<dl> <dt ng-repeat-start="item in items">{{ item.term }}</dt> <dd ng-repeat-end>{{ item.definition }}</dd></dl>
Table-like arrangement of data with display:grid:
<div style="display: grid; grid-template-columns: auto auto"> <div ng-repeat-start="item in items">{{ item.a }}</div> <div>{{ item.b }}</div> <div ng-repeat-end>{{ item.c }}</div></div>
You can read about this in API reference: https://docs.angularjs.org/api/ng/directive/ngRepeat#special-repeat-start-and-end-points
Unfortunately in AngularJS ng-repeat
, ng-if
, etc must be used on an HTML element that will be present in the markup. Depending on the exact use-case you could try using an element directive with replace: true
.
You can use the same ng-container
in both Angularjs
and Angular-2
as well. But in angular-2
have an additional option is ng-template
which is act as ng-container