1

Tried a few different solutions, not sure where exactly I'm going wrong. I know the directive is linked properly, and have tried template instead of templateURL to test if it would work that way, but nothing.

Directive:

app.directive('printTasks', function() {
return {
    restrict: 'E',
    replace: 'true',
    scope: {
        info: '='
    },
    templateUrl: '../printTasks.html'
};
});
console.log('printTasks is linked');

Calling in HTML:

            <section ng-controller="MainController">
                <header>This Week
                    <a href="">
                        <i class="fa fa-2x fa-stack-2x fa-plus"></i>
                    </a>
                </header>
                <printTasks/>
            </section>

I've also tried and that hasn't worked either. Anyone have any ideas?

2 Answers 2

3

couple of points to be considered in above case of writing derictive -

  1. You should use directive as element if using restrict: 'E' and should have custom attribute "info" as below

  2. When you are using replace:true in directive then the template should have single root element. More information

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

Comments

2

It should be use camel case while using on html, also directive element shouldn't be self closing like <printTasks/>, as you have defined you own custom element.

<print-tasks></print-tasks>

1 Comment

So you use camel case to name a directive, then it gets converted to a hyphenated format? Changing it seemed to do something anyways, the directive is still not showing up, but the console is now showing the following error: i.imgur.com/h4ZH05a.png

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.