$topmenu looks like something weird. I've no clue what that is or where
it's coming from, but if it is part of the angular hierarchy you'll need to
inject it in .directive('navigation', ['$topmenu', function($topmenu) {...
(and then close out the array at the end).If, on the other hand, $topmenu is some kind of global package added in like you'd add underscore or jquery or whatever, you'll just need to make sure you've got a <script> tag that adds that. Also: this template looks a bit funky. I'd consider talking to the author and asking for a refund. 1) declaring an angular directive named 'navigation' is kind of hinky in the first place. It potentially conflicts with any kind of other custom HTML element that is created elsewhere in your source. It's probably (definitely) a best practice to use some kind of faux-namespacing with hyphens. The directive should be fooNavigation, and the resultant html element would be foo-navigation. Pick foo to be (a) short, (b) memorable, and (c) not colliding with anything else that's common. For example on my project, I prefix all my angular directives with flo- 2) Angular directives don't need to use $, at all. That's cheating. While it works, it gives the code that "hmm, not really well-written angular" smell. But that's just IMO. $topmenu is probably something defined in a random javascript or template file somewhere. Probably need to import it and pollute that global variable namespace. e On Wed, Jun 18, 2014 at 11:03 AM, [email protected] <[email protected]> wrote: > I recently buy a template and it comes with Angular version so I'm trying > to work with this in my SF2.5 application. Right now I'm having a problem > and I can't find where it's failing since this isn't my code and I'm still > learning a bit on this. So the error is as title says "Error: $topmenu is > not defined". I find trough directives and I notice this one: > > .directive('navigation', function() { > return { > restrict: 'AE', > controller: ['$scope', function($scope) { > > }], > transclude: true, > replace: true, > link: function(scope, element, attrs) { > if (!$topmenu) { > if (!null) { > element.first().jarvismenu({ > accordion: true, > speed: $.menu_speed, > closedSign: '<em class="fa > fa-plus-square-o"></em>', > openedSign: '<em class="fa > fa-minus-square-o"></em>' > }); > } else { > alert("Error - menu anchor does not exist"); > } > } > > // SLIMSCROLL FOR NAV > if ($.fn.slimScroll) { > element.slimScroll({ > height: '100%' > }); > } > > scope.getElement = function() { > return element; > } > }, > template: '<nav><ul data-ng-transclude=""></ul></nav>' > }; > }) > > It's the only place where $topmenu is used, where is the error? Where > should I define that var in order to avoid the error? > > Thanks in advance > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
