0

I try to write my first component. Actually, I refactor one of my previous webpage to use more of the AngularJS functionality. I use AngularJS 1.5.8

Honestly I always got the following inject error: http://screencast.com/t/xpyVqSjwUxU

Here is my component code: http://screencast.com/t/zMaED5ZfZ

The error only came up, when I add the component.js file in index.html with a script tag.

Any idea, what I'm gonna mess? I read the component angularjs documentation but not find the error.

1
  • I figured it out, the component name is the problem. Intead of UpdatePasswordComponent I need to use the update-password name, and the error is gone. Commented Sep 30, 2016 at 21:23

2 Answers 2

0

Try putting the return value { templateUrl: ..., controller..., etc } in the .component() function.

angular
  .module('Profile')
  .component('UpdatePasswordComponent', {
    templateUrl: '/modules/profile/update-password/update-password.component.html',
    controller: UpdatePasswordController,
    controllerAs: 'vm'
  });
Sign up to request clarification or add additional context in comments.

Comments

0

Another option might be to just change this line

.component('UpdatePasswordComponent', Component)

to

.component('UpdatePasswordComponent', Component())

which will actually call and return the object, but I'm not positive on this one.

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.