Angular 1.5.0-beta.0: angular.module (...). The component is not a function

I am trying to use Angular 1.5.0-beta.0 , which I installed from npm .

According to some tutorials - now we can create a component using module.component instead of the old module.directive method.

This is the component code:

  export default angular.module('app.components.header', []) .component('dashboardHeader', { controller: 'HeaderCtrl as headerCtrl', template: `This is test.` }) ; 

My html:

 <body> <dashboard-header></dashboard-header> <div ui-view="content"> </body> 

I get:

 angular.module(...).component is not a function 

What could be the problem?

+5
source share
4 answers

There is nothing wrong with the code. Install stable release angular 1.5. I had the same problem and then removed angular and installed it with:

 bower install angular 
+5
source

I had the same problem. bower install angular it still threw the same error, Finally, I updated the version of angular.js in the src script tag and worked.

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> 
+5
source

Make sure you are not using an older version of Angular JS CDN

+1
source

I had the same problem for meteor js (AngularJs with MeteorJs). We need to update the angularjs version. In my case, I upgraded 1.4.8 to 1.5.3 , and then restarted the meteor server, the error was resolved.

Command to update angular js ( In case of meteor )

meteor update angular: angular - this will update the angular system to the latest available version.

0
source

Source: https://habr.com/ru/post/1235968/


All Articles