0

I am developing a mobile application with left and right drawer, using mmenu (http://mmenu.frebsite.nl/) it is working fine till I've decided to populate items of the right menu on the fly. My app is based on angularjs and all directives of angularjs in body are working fine except all directives inside <nav id="menu-right">somehow, angularjs directives inside the menu definitions are not executed. I am not sure if it is something related with the order of executing javascript. Any help will be really appreciated. Thank you !!

UPDATED (07-April)

An example in jsfiddle http://jsfiddle.net/jmhostalet/wcK8L/

"My controller says" is working in the body but not in the mmenu, in body prints "Hello" but in mmenu prints nothing

jmhostalet
  • 4,399
  • 4
  • 38
  • 47

2 Answers2

0

The problems you were running into were:

  1. First off the was not included in the declaration
  2. You are changing the DOM without angular knowing about it therefor it does not have a chance to compile the braces {{myCtrlVar}}

It seems like extra work to create a directive but in the long run will allow you to reuse your code more. Also if you are like me and have bad javascript habits; it is nicer to use a framework to keep things straight.

My solution the in the plunker below shows "one way" to do what you are asking. It would be interesting to port the entire MMenu code over to an angular module in order to have more parameters and control.

(Never heard of MMenu, but seems like a cool project -- I will look more into it).

Plunker

(sorry I am inept at using fiddler)

Community
  • 1
  • 1
Cory Silva
  • 2,761
  • 17
  • 23
  • Thank you, it is working. Anyway I've found quite difficult extending the directive to use other internal methods from mmenu, therefore I've decided building my own drawer from scratch using angularjs. Thanks anyway!! – jmhostalet May 21 '14 at 07:38
0

Your fiddle doesn't have controller initialization on #menu-right but on his sibling element and therefore {{myCtrlVar}} expression can't access controllers scope objects.