Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom components not working #3

Open
ShakedGold opened this issue Nov 30, 2023 · 0 comments
Open

Custom components not working #3

ShakedGold opened this issue Nov 30, 2023 · 0 comments

Comments

@ShakedGold
Copy link

I tried using the external file with templateUrl and for some reason didn't see anything, so I tried to create a component like so:

angular.module(NAME).component('test', {
            template: `
                <div>
  <button ng-click="$ctrl.updateCounter()">Add Item</button>
  <button ng-click="$ctrl.resetCounter()">Reset Items</button>
  <pre>{{ $ctrl.items }}</pre>
</div>
                `,
            controller: function() {
                this.items = [];
                this.updateCounter = function() {
                    this.items.push(this.items.length);
                };
                this.resetCounter = function() {
                    this.items = [];
                };
            },
        });

and used it like this:

component() {
            return {
                template: `
                    <div>
                        <test></test>
                    </div>
                `,
                $ctrl: { },
    };
},

but nothing is showing up, in the html of the app it just inserts: and not the normal HTML.
when I put the component in the string instead on creating the component everything works fine.

I don't really know angular so I might have missed something but I checked didn't find anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant