0

i have created menu directive like this in app.js.

.directive('menuShow', function () {
        return {
            restrict: 'EA',
            templateUrl: 'shared/menu.html',
        }
    });

Directive is used in index page as:

<menu-show ></menu-show>

Now, i want to write functionality code which will be used in menu.html directive.

how to write controller for menu.html.

1 Answer 1

1

You can create a controller for your directive and set this in directive,

 .directive('menuShow', function () {
        return {
            restrict: 'EA',
            templateUrl: 'shared/menu.html',
            controller: menuCtrl,
            controllerAs: 'test',
            bindToController: true
        }
    });
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.