This is a shortened version of the js file
var linksManager = angular.module('linksManager', ['ui']);
angular.bootstrap(document, ['linksManager']);
linksManager.factory('linksData', function () {
var linksData = [
{
text: 'Menu Item 1',
url: '#'
}, {
text: 'Menu Item 2',
url: '#',
submenu: [
// more data ...
});
function linksRarrange($scope, linksData) { $scope.links = linksData; }
Before the linksData was directly inside the linksRearrange controller
$scope.links = [
{
text: 'Menu Item 1',
url: '#'
}, {
text: 'Menu Item 2',
url: '#',
submenu: [
// more data ...
And it worked fine, why the sharing doesn't work now?
This is the HTML, it doesn't display anything now:
<div class="nav-manage clearfix" ng-app="linksManager">
<div class="links-arrange" ng-controller="linksRarrange">
<ul class="sortable">
<li ng-repeat="level1link in links">
<a href="{{level1link.url}}">{{level1link.text}}</a>
<ul class="sortable">
<li ng-repeat='level2link in level1link.submenu'>
<a href="{{level2link.url}}">{{level2link.text}}</a>
<ul class="sortable">
<li ng-repeat='level3link in link.level2link'>
<a href="{{level3link.url}}">{{level3link.text}}</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
factory of angular is supposed to return the object.
I think you forgot to
return linksData;
at the end of the factory function.