Recursion angular directives Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!$watch'ing for data changes in an Angular directiveWhat is the difference between '@' and '=' in directive scope in AngularJS?Recursion in Angular directivesHow to call a method defined in an AngularJS directive?How to access parent scope from within a custom directive *with own scope* in AngularJS?What is the difference between Polymer elements and AngularJS directives?Angular directive with default optionsAngular ng-style with a conditional expressionWhat is the difference between angular-route and angular-ui-router?Angular directives - when and how to use compile, controller, pre-link and post-link
Do i imagine the linear (straight line) homotopy in a correct way?
How many time has Arya actually used Needle?
How does the body cool itself in a stillsuit?
As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?
What is the proper term for etching or digging of wall to hide conduit of cables
Why is there so little support for joining EFTA in the British parliament?
Why does BitLocker not use RSA?
Pointing to problems without suggesting solutions
The Nth Gryphon Number
How to make triangles with rounded sides and corners? (squircle with 3 sides)
3D Masyu - A Die
Understanding piped commands in GNU/Linux
What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?
By what mechanism was the 2017 UK General Election called?
Shimano 105 brifters (5800) and Avid BB5 compatibility
First paper to introduce the "principal-agent problem"
How to ask rejected full-time candidates to apply to teach individual courses?
Any stored/leased 737s that could substitute for grounded MAXs?
Can gravitational waves pass through a black hole?
.bashrc alias for a command with fixed second parameter
How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?
Can I cut the hair of a conjured korred with a blade made of precious material to harvest that material from the korred?
How to achieve cat-like agility?
The test team as an enemy of development? And how can this be avoided?
Recursion angular directives
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!$watch'ing for data changes in an Angular directiveWhat is the difference between '@' and '=' in directive scope in AngularJS?Recursion in Angular directivesHow to call a method defined in an AngularJS directive?How to access parent scope from within a custom directive *with own scope* in AngularJS?What is the difference between Polymer elements and AngularJS directives?Angular directive with default optionsAngular ng-style with a conditional expressionWhat is the difference between angular-route and angular-ui-router?Angular directives - when and how to use compile, controller, pre-link and post-link
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I need to use recursion in angular directives.
Follow the code with the template without recursion.
It is a left menu that must be created recursively.
I'm not sure how to put the recursion.
I tried '<leftmenu menuLeft = "itemmenu"> </ leftmenu>'
, but so only the profile image appears several times.
.directive('leftmenu', ['$compile', function ($compile)
return
retrict: 'E',
scope: menuLeft: '=?' ,
template: '<div class="user-panel">' +
'<div class= "pull-left image">' +
'<img src=" menuLeft.profileImgSrc " class="img-circle" alt=" menuLeft.profileName " />' +
'</div>' +
'<div class="pull-left info">' +
'<p> menuLeft.profileName </p>' +
'</div>' +
'</div>' +
'<ul class="sidebar-menu">' +
'<li class="header"> menuLeft.header </li>' +
'<li class="treeview" ng-repeat="itemmenu in menuLeft.itens">' +
'<a href=" itemmenu.actionLink ">' +
'<i class=" itemmenu.visualClass "></i> <span> itemmenu.label </span>' +
'<span class="pull-right-container" ng-show=" itemmenu.subItems.length > 0 ">' +
'<i class="fa fa-angle-left pull-right"></i>' +
'</span>' +
'</a>' +
'<ul class="treeview-menu">' +
'<li ng-repeat="subItem in itemmenu.subItems">' +
'<a ng-if="subItem.openInNewWindow" target="_blank" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'<a ng-if="!subItem.openInNewWindow" target="_self" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'</li>' +
'</ul>' +
'</li>' +
'</ul>',
compile: function (element)
,
controller: function ($location, $http, $scope)
$scope.menuLeft =
"profileName": "",
"profileImgSrc": response.data.msgSaida[0].profileImgSrc,
"header": "",
"itens": response.data.msgSaida[0].itens,
"token": token
;
}
};
angularjs angularjs-directive
add a comment |
I need to use recursion in angular directives.
Follow the code with the template without recursion.
It is a left menu that must be created recursively.
I'm not sure how to put the recursion.
I tried '<leftmenu menuLeft = "itemmenu"> </ leftmenu>'
, but so only the profile image appears several times.
.directive('leftmenu', ['$compile', function ($compile)
return
retrict: 'E',
scope: menuLeft: '=?' ,
template: '<div class="user-panel">' +
'<div class= "pull-left image">' +
'<img src=" menuLeft.profileImgSrc " class="img-circle" alt=" menuLeft.profileName " />' +
'</div>' +
'<div class="pull-left info">' +
'<p> menuLeft.profileName </p>' +
'</div>' +
'</div>' +
'<ul class="sidebar-menu">' +
'<li class="header"> menuLeft.header </li>' +
'<li class="treeview" ng-repeat="itemmenu in menuLeft.itens">' +
'<a href=" itemmenu.actionLink ">' +
'<i class=" itemmenu.visualClass "></i> <span> itemmenu.label </span>' +
'<span class="pull-right-container" ng-show=" itemmenu.subItems.length > 0 ">' +
'<i class="fa fa-angle-left pull-right"></i>' +
'</span>' +
'</a>' +
'<ul class="treeview-menu">' +
'<li ng-repeat="subItem in itemmenu.subItems">' +
'<a ng-if="subItem.openInNewWindow" target="_blank" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'<a ng-if="!subItem.openInNewWindow" target="_self" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'</li>' +
'</ul>' +
'</li>' +
'</ul>',
compile: function (element)
,
controller: function ($location, $http, $scope)
$scope.menuLeft =
"profileName": "",
"profileImgSrc": response.data.msgSaida[0].profileImgSrc,
"header": "",
"itens": response.data.msgSaida[0].itens,
"token": token
;
}
};
angularjs angularjs-directive
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19
add a comment |
I need to use recursion in angular directives.
Follow the code with the template without recursion.
It is a left menu that must be created recursively.
I'm not sure how to put the recursion.
I tried '<leftmenu menuLeft = "itemmenu"> </ leftmenu>'
, but so only the profile image appears several times.
.directive('leftmenu', ['$compile', function ($compile)
return
retrict: 'E',
scope: menuLeft: '=?' ,
template: '<div class="user-panel">' +
'<div class= "pull-left image">' +
'<img src=" menuLeft.profileImgSrc " class="img-circle" alt=" menuLeft.profileName " />' +
'</div>' +
'<div class="pull-left info">' +
'<p> menuLeft.profileName </p>' +
'</div>' +
'</div>' +
'<ul class="sidebar-menu">' +
'<li class="header"> menuLeft.header </li>' +
'<li class="treeview" ng-repeat="itemmenu in menuLeft.itens">' +
'<a href=" itemmenu.actionLink ">' +
'<i class=" itemmenu.visualClass "></i> <span> itemmenu.label </span>' +
'<span class="pull-right-container" ng-show=" itemmenu.subItems.length > 0 ">' +
'<i class="fa fa-angle-left pull-right"></i>' +
'</span>' +
'</a>' +
'<ul class="treeview-menu">' +
'<li ng-repeat="subItem in itemmenu.subItems">' +
'<a ng-if="subItem.openInNewWindow" target="_blank" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'<a ng-if="!subItem.openInNewWindow" target="_self" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'</li>' +
'</ul>' +
'</li>' +
'</ul>',
compile: function (element)
,
controller: function ($location, $http, $scope)
$scope.menuLeft =
"profileName": "",
"profileImgSrc": response.data.msgSaida[0].profileImgSrc,
"header": "",
"itens": response.data.msgSaida[0].itens,
"token": token
;
}
};
angularjs angularjs-directive
I need to use recursion in angular directives.
Follow the code with the template without recursion.
It is a left menu that must be created recursively.
I'm not sure how to put the recursion.
I tried '<leftmenu menuLeft = "itemmenu"> </ leftmenu>'
, but so only the profile image appears several times.
.directive('leftmenu', ['$compile', function ($compile)
return
retrict: 'E',
scope: menuLeft: '=?' ,
template: '<div class="user-panel">' +
'<div class= "pull-left image">' +
'<img src=" menuLeft.profileImgSrc " class="img-circle" alt=" menuLeft.profileName " />' +
'</div>' +
'<div class="pull-left info">' +
'<p> menuLeft.profileName </p>' +
'</div>' +
'</div>' +
'<ul class="sidebar-menu">' +
'<li class="header"> menuLeft.header </li>' +
'<li class="treeview" ng-repeat="itemmenu in menuLeft.itens">' +
'<a href=" itemmenu.actionLink ">' +
'<i class=" itemmenu.visualClass "></i> <span> itemmenu.label </span>' +
'<span class="pull-right-container" ng-show=" itemmenu.subItems.length > 0 ">' +
'<i class="fa fa-angle-left pull-right"></i>' +
'</span>' +
'</a>' +
'<ul class="treeview-menu">' +
'<li ng-repeat="subItem in itemmenu.subItems">' +
'<a ng-if="subItem.openInNewWindow" target="_blank" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'<a ng-if="!subItem.openInNewWindow" target="_self" href=" subItem.actionLink ">' +
'<i subItem.class ></i> subItem.label ' +
'</a>' +
'</li>' +
'</ul>' +
'</li>' +
'</ul>',
compile: function (element)
,
controller: function ($location, $http, $scope)
$scope.menuLeft =
"profileName": "",
"profileImgSrc": response.data.msgSaida[0].profileImgSrc,
"header": "",
"itens": response.data.msgSaida[0].itens,
"token": token
;
}
};
angularjs angularjs-directive
angularjs angularjs-directive
edited Mar 22 at 23:05
georgeawg
35k115470
35k115470
asked Mar 22 at 13:31
Danielle RodriguesDanielle Rodrigues
61
61
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19
add a comment |
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19
add a comment |
1 Answer
1
active
oldest
votes
A little late to the party, if you're still looking to resolve this with a recursive directive, it depends what your data structure looks like, but assuming from what you've posted it looks like this:
"profileName": "",
...
"items": [
"label": "title1",
"class": "class1",
"items: [...]
,
"label": "title1",
"class": "class1",
"items: [...]
]
You can split them into two directives:
- One is the parent sidePanel directive that contains the top level
- One is the menuList directive that will recursively display sub items
// profile image
// profile name
// etc
<menu-list items="leftMenu.items"></menu-list>
where menu list template was like:
<ul>
<li ng-repeat="item in items">
<span class="item.class">item.label</span>
<menu-list ng-if="item.items" items="item.items"></menu-list>
</li>
</ul>
So in each instance of a menu object (label,class,items) the items will be converted into a sub menu-list. You might need to play with it a little and add in some other features.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300749%2frecursion-angular-directives%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A little late to the party, if you're still looking to resolve this with a recursive directive, it depends what your data structure looks like, but assuming from what you've posted it looks like this:
"profileName": "",
...
"items": [
"label": "title1",
"class": "class1",
"items: [...]
,
"label": "title1",
"class": "class1",
"items: [...]
]
You can split them into two directives:
- One is the parent sidePanel directive that contains the top level
- One is the menuList directive that will recursively display sub items
// profile image
// profile name
// etc
<menu-list items="leftMenu.items"></menu-list>
where menu list template was like:
<ul>
<li ng-repeat="item in items">
<span class="item.class">item.label</span>
<menu-list ng-if="item.items" items="item.items"></menu-list>
</li>
</ul>
So in each instance of a menu object (label,class,items) the items will be converted into a sub menu-list. You might need to play with it a little and add in some other features.
add a comment |
A little late to the party, if you're still looking to resolve this with a recursive directive, it depends what your data structure looks like, but assuming from what you've posted it looks like this:
"profileName": "",
...
"items": [
"label": "title1",
"class": "class1",
"items: [...]
,
"label": "title1",
"class": "class1",
"items: [...]
]
You can split them into two directives:
- One is the parent sidePanel directive that contains the top level
- One is the menuList directive that will recursively display sub items
// profile image
// profile name
// etc
<menu-list items="leftMenu.items"></menu-list>
where menu list template was like:
<ul>
<li ng-repeat="item in items">
<span class="item.class">item.label</span>
<menu-list ng-if="item.items" items="item.items"></menu-list>
</li>
</ul>
So in each instance of a menu object (label,class,items) the items will be converted into a sub menu-list. You might need to play with it a little and add in some other features.
add a comment |
A little late to the party, if you're still looking to resolve this with a recursive directive, it depends what your data structure looks like, but assuming from what you've posted it looks like this:
"profileName": "",
...
"items": [
"label": "title1",
"class": "class1",
"items: [...]
,
"label": "title1",
"class": "class1",
"items: [...]
]
You can split them into two directives:
- One is the parent sidePanel directive that contains the top level
- One is the menuList directive that will recursively display sub items
// profile image
// profile name
// etc
<menu-list items="leftMenu.items"></menu-list>
where menu list template was like:
<ul>
<li ng-repeat="item in items">
<span class="item.class">item.label</span>
<menu-list ng-if="item.items" items="item.items"></menu-list>
</li>
</ul>
So in each instance of a menu object (label,class,items) the items will be converted into a sub menu-list. You might need to play with it a little and add in some other features.
A little late to the party, if you're still looking to resolve this with a recursive directive, it depends what your data structure looks like, but assuming from what you've posted it looks like this:
"profileName": "",
...
"items": [
"label": "title1",
"class": "class1",
"items: [...]
,
"label": "title1",
"class": "class1",
"items: [...]
]
You can split them into two directives:
- One is the parent sidePanel directive that contains the top level
- One is the menuList directive that will recursively display sub items
// profile image
// profile name
// etc
<menu-list items="leftMenu.items"></menu-list>
where menu list template was like:
<ul>
<li ng-repeat="item in items">
<span class="item.class">item.label</span>
<menu-list ng-if="item.items" items="item.items"></menu-list>
</li>
</ul>
So in each instance of a menu object (label,class,items) the items will be converted into a sub menu-list. You might need to play with it a little and add in some other features.
answered Apr 16 at 15:39
kendavidsonkendavidson
10810
10810
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300749%2frecursion-angular-directives%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It may be just me, but I am not able to understand your requirement . Can you add some use case and a sample wireframe(boxes drawn from Microsoft paint would also do) to understand it
– Shashank Vivek
Mar 22 at 18:19