Ok, I'm trying to create a categories browser, something like eBay, using AngularJS.
I have the root categories:
<div id='root'>
<ul>
<li data-ng-repeat='category in categories'>
<a href='#'
data-ng-bind='category.Name'
data-ng-click='browseCategories(category, "children-1")'>
</a>
</li>
</ul>
</div>
<div id='children-1'>
</div>
<div id='children-2'>
</div>
The purpose of the browseCategories
method is to fill children-1
div with the children of the selected category.
$scope.browseCategories = function(category, moveTo) {
//looping in order to create a new <ul> of children categories.
var html = "<ul class='unstyled'>";
for (var I = 0; I < category.Children.length; ++I) {
var category = category.Children[I];
html += "<li><a href='#' data-ng-click='browseCategories(" +
category + ", 'children-1')'>" + category.Name + "</a>";
}
html += "</ul>";
var elMoveTo = angular.element(moveTo);
$(elMoveTo).html(html);
}
Well, the new <ul>
is properly attached to the element, but the browseCategories
method stops to work. What's happening?
Thanks for all