-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ng-repeat inside template does not seem to work (demo) #43
Comments
Seem related to this anguar issue. I tried the mentioned workaround which is to wrap |
As a quick workaround, for anyone interested, here is a very basic directive to replace // Example markup : <div no-scope-repeat items="card.items"></div>
.directive('noScopeRepeat', function($compile) {
return function(scope, elem, attrs) {
scope.$watch(attrs.items, function(items) {
if (!items) return;
// Example template that will be repeated, with above markup,
// #OBJ#.myValue will be replaced by card.items[idx].myValue at each step
var template = '<div>{{ #OBJ#.myValue }}</div>';
items.forEach(function(val, key) {
var newElement = angular.element(
template.replace(/#OBJ#/g, attrs.items + '[' + key + ']')
);
$compile(newElement)(scope);
elem.append(newElement);
});
});
};
}) Anyone makes a transcluded version I'm interested :-) |
@pandaiolo This is how I implemented it. I'm not sure this is the most efficient way but it allows me to use custom template import, more flexible. template
included template (partial_comment_list.html)
directive
UPDATE: directive is now working as it should. example:
|
Indeed, it does work. I was able to have ng-repeat div work within the template file and render different templates for different listing styles. I have experience and confidence working with Directives in AngularJS. |
Why is it not possible to use
ng-repeat
inside adeckgrid
whileng-repeat
can be used recursively ?Demonstration of both non-working (deckgrid) and working (ng-repeat) behaviour here : (http://codepen.io/anon/pen/nfzHk/)
The text was updated successfully, but these errors were encountered: