0

I'm pretty new to angular and I'm doing a custom directive on angular, which will display a list, but I have no idea how to pass parameters from html to js, for example:

<div data-ng-menu="['Home','Settings','About']"></div>

and js file

var app = angular.module("myApp", []);
app.directive('ngMenu', function ($parse) {
    var menu = {};
    menu.restrict = 'A';
    menu.template = "<ul><li>parse</li></ul>";
    return menu;
});

It should display like this:

  • Home
  • Settings
  • About

1 Answer 1

3

I suggest that you take a step back and read through some of the Angular documentation for directive. Angular is quite different than jQuery and you shouldn't try to force jQuery idioms into your Angular implementation.

https://docs.angularjs.org/guide/directive

I know I did not answer your question but I fear that just rewriting your code to provide the answer will do you more harm in the long run.

Good luck.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.