aarffy
aarffy

Reputation: 231

Angularjs components no longer work

Woke up this morning to find my app lo longer works. It uses a component framework similar to that used in the Angular-ui-router tutorial Hello Galaxy ( https://ui-router.github.io/tutorial/ng1/hellogalaxy ), which also doesn't work as of this morning.

States like this:

    var states = [
    { name: 'hello', url: '/hello', component: 'hello' },
    { name: 'about', url: '/about', component: 'about' }]

States are then registered.

Components like this:

angular.module('app').component('hello', {
  template:  '<h3>{{$ctrl.greeting}} galaxy!</h3>' +
     '<button ng-click="$ctrl.toggleGreeting()">toggle greeting</button>',

  controller: function() {
    this.greeting = 'hello';

    this.toggleGreeting = function() {
        this.greeting = (this.greeting == 'hello') ? 'whats up' : 'hello'
    }
}

})

I'm using Angular 1.58 and the latest ui-router.

Error message is: Uncaught TypeError: angular.module(...).component is not a function(anonymous function) @ hello.js:1 about.js:1 Uncaught TypeError: angular.module(...).component is not a function(anonymous function) @ about.js:1, etc.

Last night both my app and ui-router's app worked fine.

Upvotes: 0

Views: 380

Answers (1)

aarffy
aarffy

Reputation: 231

Ok. The ui-router demo, as well as my app was using

<script src="//unpkg.com/angular@latest/angular.js"></script>

This is now returning AngularJS v1.2.32 instead of Angular 1.5.8. Therein lies the prob. I just changed to

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>

This solved the problem.

Upvotes: 0

Related Questions